title: Passing modified user defined properties to auth
body: <p>I am to trying to evaluate a user's role as soon as they login into the system so i can avoid querying the database every time a user's role needs to be evaluated that is to say running <code>auth()-&gt;user()-&gt;role-&gt;role_name</code>.</p>
  
  <p>Here is a look at my User model</p>
  
  <pre><code>&lt;?php
  
  namespace App;
  
  use Illuminate\Notifications\Notifiable;
  use Illuminate\Foundation\Auth\User as Authenticatable;
  
  Use App\Library\Hash;
  
  class User extends Authenticatable
  {
      use Notifiable;
  
      public $is_admin;
  
      public $is_employer;
  
      // Pagination size
      protected $perPage = 10;
  
      // Table name
      protected $table = 'user';
  
      // Primary Key
      protected $primaryKey = 'user_id';
  
      // Add new datetime column for carbon use
      protected $dates = ['last_login', ];
  
      // User Role Foreign Key
      protected $userRoleForeignKey = 'role_id';
  
      /**
       * The attributes that are mass assignable.
       *
       * @var array
       */
      protected $fillable = [
          'email', 'password', 'salt', 'email_hash', 'active'
      ];
  
      /**
       * The attributes that should be hidden for arrays.
       *
       * @var array
       */
      protected $hidden = [
          'password', 'salt', 'remember_token',
      ];
  
      public function checkUserRole() {
          $role = $this-&gt;role-&gt;role_name;
  
          if ( $role == 'admin' ) {
              $this-&gt;is_admin = true;
          } else if ( $role == 'employer' ) {
              $this-&gt;is_employer = true;
          }
  
          return $this;
      }
  
      public function role() {
          return $this-&gt;belongsTo(
                  'App\UserRole',
                  $this-&gt;userRoleForeignKey
              );
      }
  </code></pre>
  
  <p>As you can see i have added two properties at the top of my class <code>$is_admin</code> and  <code>$is_employer</code> to help me determine a user's role and i have also added the method <code>checkUserRole</code> run every time a user is logging in.</p>
  
  <p>Below is the <code>login</code> method in the <code>SessionsController</code></p>
  
  <pre><code>    public function login(Request $request) 
      {
          $this-&gt;validate($request, [
                  'email' =&gt; 'required|email',
                  'password' =&gt; 'required',
              ], [
                  'email.required' =&gt; 'Email is required',
                  'password.required' =&gt; 'Password is required',
              ]);
  
          $user = User::where('email', '=', $request-&gt;email)-&gt;first();
  
          if ( !$user || !($user-&gt;checkCredentials($request-&gt;password)) ) {
              return back()-&gt;with([
                      'class' =&gt; 'alert-danger',
                      'message' =&gt; 'Please check your credentials'
                  ]);
          }
  
          $user = $user-&gt;checkUserRole();
  
          auth()-&gt;login($user);
  
          dd( auth()-&gt;user() );
  
          return redirect('/dashboard');
      }
  </code></pre>
  
  <p>Below is a screenshot from when i login as an employer and it hits the <code>dd</code> function.
  <a href="https://i.stack.imgur.com/ZTSCl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZTSCl.png" alt="enter image description here"></a></p>
  
  <p>As you see from the screenshot, the <code>$is_employer</code> property is set to true.</p>
  
  <p>Problem is when i comment out the <code>dd</code> function in the <code>login</code> and am redirected to the dashboard controlled by the <code>index</code> method of the <code>DashboardController</code> class as shown below</p>
  
  <pre><code>public function index()
  {
      dd( auth()-&gt;user()-&gt;is_employer );
  }
  </code></pre>
  
  <p>I get the output of <code>null</code> from the <code>dd</code> function.</p>
  
  <p>Why would the output be <code>null</code> when it is clearly showing it is true just before redirection?</p>