title: Laravel 5 custom user Auth methods
body: <p>My authenticated user has a color assigned to them via a relationship in the User model.</p>
  
  <p>I would like to go:</p>
  
  <pre><code>return Auth::color()-&gt;id;
  </code></pre>
  
  <p>To return the logged in users color id.</p>
  
  <p>How do I go about doing this?</p>
  
  <p>I also can't do:</p>
  
  <pre><code>Auth::user()-&gt;color()-&gt;id
  </code></pre>
  
  <p>or</p>
  
  <pre><code>Auth::user()-&gt;color-&gt;id
  </code></pre>
  
  <p>I am getting <code>Undefined property: Illuminate\Database\Eloquent\Relations\BelongsTo::$id</code></p>
  
  <p>However all relationships are defined.</p>
  
  <p>I am coming from Laravel 4, what am I doing wrong?</p>
  
  <hr>
  
  <pre><code>&lt;?php
  
  namespace App\Models;
  
  use Illuminate\Auth\Authenticatable;
  use Illuminate\Database\Eloquent\Model;
  use Illuminate\Auth\Passwords\CanResetPassword;
  use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
  use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
  
  class User extends Model implements AuthenticatableContract, CanResetPasswordContract
  {
      use Authenticatable, CanResetPassword;
  
      protected $table = 'users';
  
      protected $fillable = ['name', 'email', 'password'];
  
      protected $hidden = ['password', 'remember_token'];
  
      public function color() {
          return $this-&gt;hasOne('\App\Models\Colour');
      }
  
      public function salesarea() {
          return $this-&gt;belongsTo('\App\Models\Salesarea');
      }
  
      public function getNameAttribute() {
          return $this-&gt;first_name." ".$this-&gt;last_name;
      }
  
  }
  </code></pre>