laravel-4

Laravel: URL::to('/') port number for localhost not included in db seed files

☆樱花仙子☆ 提交于 2020-04-10 15:09:10
问题 I am running a local server on port 4567. I am trying to make it so that when my database seeds I save a reference to the home page on my site in my db. However I noticed when I run URL::to('/') in my seeds it only includes "localhost" without the port, but if I include it in my view code it comes out as "localhost:4567". Why is this? How can I fix it, if possibly, without writing if statement conditionals about what production environment I am in? Thank you. Seed File result of URL::to('/')

How to get all rows (soft deleted too) from a table in Laravel?

浪子不回头ぞ 提交于 2020-04-07 16:57:35
问题 To get all rows from a table, I have to use Model::all() but (from good reason) this doesn't gives me back the soft deleted rows. Is there a way I can accomplish this with Eloquent? 回答1: To also get soft deleted models $trashedAndNotTrashed = Model::withTrashed()->get(); Only soft deleted models in your results $onlySoftDeleted = Model::onlyTrashed()->get(); 回答2: Use this to get all record Model::withTrashed()->get(); Use this to get record of particular id Property::withTrashed()->find($list

Composer/Laravel: How to add/update a specific package

♀尐吖头ヾ 提交于 2020-04-07 12:50:17
问题 How do you add/update a specific package using composer? I'm using the latest Laravel as well not sure if it matters but anything that can help to determine the answer. I have also tried the following from an old Stackoverflow post I had found, but it didn't work for me. It appended the package to composer.json and then proceeded to update everything anyways. Here is the link: How to update a single library with Composer? And here is the package I tried to add to my project: https://github

Laravel 4 's all() method started to return Eloquent collection lately - why?

本小妞迷上赌 提交于 2020-03-04 23:07:16
问题 This is my controller: return View::make('home.listings') ->with('listings', Listing::all()); Previously, I checked it on views like this: (and it worked on all my projects) @if(!empty($listings)) //use foreach and show listings @else <h3>No listing is found.</h3> @endif This is my Listing model. class Listing extends Eloquent { public static $key = 'id'; protected $table = 'ilanlar'; public $timestamps = false; } Right now, it works when there is an entry in database. However, when there is

Database seeding - insert multiple records in one query

☆樱花仙子☆ 提交于 2020-03-04 05:56:51
问题 I have a Laravel project where I would like to insert above 900 cities into database as database seeding. For example I could do it this way: $state_id = State::whereName('state name')->pluck('id'); $city = new City(); $city->name = 'my city name'; $city->state_id = $state_id; $city->save(); and in my City model I have defined save as: public function save(array $options = array()) { $this->url = $this->createUrl($this->name); parent::save($options); } so it creates also url for the city. I

Command is not defined exception

走远了吗. 提交于 2020-02-23 08:49:19
问题 I created a command with Artisan $ php artisan command:make NeighborhoodCommand This created the file app/commands/NeighborhoodCommand.php Snippet of the code. I modified the name value and filled in the fire() function <?php use Illuminate\Console\Command; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputArgument; class NeighborhoodCommand extends Command { protected $name = 'neighborhood'; public function fire() { // my code } } But then when I try

Laravel list() with each() function error with deprecated function

岁酱吖の 提交于 2020-02-23 07:25:09
问题 I get a little confuse here on how to alternatively replace the each() function since it was deprecated and I'm aware of that and fixed some of the while( list() = each() ) error case in my project. However, what other option should I use for this case: foreach($new_id as $new_ids) { list($key,$valueAddress) = each($address); list($key,$valueCity) = each($city); list($key,$valueState) = each($state); if(isset($_POST['publicOnly'])) { list($key,$valuePublicOnly) = each($publicOnly); } else {

How to create an Hstore column type in Laravel 4?

谁说我不能喝 提交于 2020-02-22 08:21:38
问题 I'm using the Schema Builder inside of Migrations in Laravel 4 to manage my Postgres database during development. I've run into a problem. I want to utilize the Postgres Hstore column type in my table but I can't figure it out. There doesn't seem to be a "custom" column type in the Schema Builder (that I can find), so this was my attempt inside of a migration. This didn't work for me. Schema::create('entities', function(Blueprint $table) { $table->bigIncrements('id'); $table->string('type');

Laravel auth CORS issue

无人久伴 提交于 2020-02-08 09:13:18
问题 I'm having the same issue with Laravel authentication and CORS as this thread: Auth::user() returns null with CORS requests Although, my files won't be hosted on the same domain as they will be used within a Cordova smartphone application. Does anyone have any ideas how to solve this, and still use Laravels standard Auth functionality? Many thanks! 回答1: Solved this by first adding the following headers to App::before function in routes: header('Access-Control-Allow-Origin: *'); header('Access

Laravel auth CORS issue

萝らか妹 提交于 2020-02-08 09:13:00
问题 I'm having the same issue with Laravel authentication and CORS as this thread: Auth::user() returns null with CORS requests Although, my files won't be hosted on the same domain as they will be used within a Cordova smartphone application. Does anyone have any ideas how to solve this, and still use Laravels standard Auth functionality? Many thanks! 回答1: Solved this by first adding the following headers to App::before function in routes: header('Access-Control-Allow-Origin: *'); header('Access