How to place the ~/.composer/vendor/bin directory in your PATH?

To put this folder on the PATH environment variable type export PATH=”$PATH:$HOME/.composer/vendor/bin” This appends the folder to your existing PATH, however, it is only active for your current terminal session. If you want it to be automatically set, it depends on the shell you are using. For bash, you can append this line to $HOME/.bashrc … Read more

Laravel Migration Change to Make a Column Nullable

Laravel 5 now supports changing a column; here’s an example from the offical documentation: Schema::table(‘users’, function($table) { $table->string(‘name’, 50)->nullable()->change(); }); Source: http://laravel.com/docs/5.0/schema#changing-columns Laravel 4 does not support modifying columns, so you’ll need use another technique such as writing a raw SQL command. For example: // getting Laravel App Instance $app = app(); // getting laravel … Read more

Laravel 5 – artisan seed [ReflectionException] Class SongsTableSeeder does not exist

You need to put SongsTableSeeder into file SongsTableSeeder.php in the same directory where you have your DatabaseSeeder.php file. And you need to run in your console: composer dump-autoload to generate new class map and then run: php artisan db:seed I’ve just tested it. It is working without a problem in Laravel 5

How to Get the Current URL Inside @if Statement (Blade) in Laravel 4?

You can use: Request::url() to obtain the current URL, here is an example: @if(Request::url() === ‘your url here’) // code @endif Laravel offers a method to find out, whether the URL matches a pattern or not if (Request::is(‘admin/*’)) { // code } Check the related documentation to obtain different request information: http://laravel.com/docs/requests#request-information

Eloquent Collection: Counting and Detect Empty

When using ->get() you cannot simply use any of the below: if (empty($result)) { } if (!$result) { } if ($result) { } Because if you dd($result); you’ll notice an instance of Illuminate\Support\Collection is always returned, even when there are no results. Essentially what you’re checking is $a = new stdClass; if ($a) { … … Read more

Laravel – Eloquent “Has”, “With”, “WhereHas” – What do they mean?

With with() is for eager loading. That basically means, along the main model, Laravel will preload the relationship(s) you specify. This is especially helpful if you have a collection of models and you want to load a relation for all of them. Because with eager loading you run only one additional DB query instead of … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)