Category Archives: Laravel 5

add data to session variables laravel

Auth::user()->setAttribute('key','value');
 unset(Auth::user()->key);

reference:

https://stackoverflow.com/questions/29190058/laravel-add-and-remove-auth-session-variables

Laravel sniff DB query builder

DB::listen(function ($query) {
    // $query->sql
    // $query->bindings
    // $query->time
});

Laravel 5 + AngularJS csrf token rename

It appears that laravel 5 no longer users the token name csrf_token, this has been abbreviated to _token.

Laravel 5 – Environment gotcha

Out of the box, laravel 5 is set to production environment.

If you use homestead for your development, you are going to have a lot of headache unless you set the environment to local.

The documentation is not clear on how to do this.

In the root folder, create a file within bootstrap/

environment.php

<php
$env = $app->detectEnvironment(function()
{
    return getenv('APP_ENV') ?: 'development';
});
?>

This is the correct way to set your environment to local, and will allow you to process your migrations as you would expect them.