title: Undefined property in model
body: <p>User model:</p>
  
  <pre><code>class User extends Authenticatable
  {
      use Notifiable;
  
      protected $table = 'users';
  
      /**
       * The attributes that are mass assignable.
       *
       * @var array
       */
      protected $fillable = [
          'name', 'email', 'password',
      ];
  
      /**
       * The attributes that should be hidden for arrays.
       *
       * @var array
       */
      protected $hidden = [
          'password', 'remember_token', 'role_id',
      ];
  
      protected $appends = [
          'role',
      ];
  
      public function getRoleAttribute()
      {
          return $this-&gt;role-&gt;name;
      }
  
      /**
       * User role.
       *
       * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
       */
      public function role()
      {
          return $this-&gt;belongsTo('App\Role');
      }
  }
  </code></pre>
  
  <p>I wan't to show the name of a role instead the role id.</p>
  
  <p>But it says:</p>
  
  <p><em>ErrorException in User.php line 38:
  Undefined property: App\User::$role</em></p>
  
  <p>The roles table contains an <strong>id</strong> and <strong>name</strong></p>
  
  <p>The users table contains a <strong>role_id</strong></p>
  
  <p><strong>Edit:</strong></p>
  
  <p>When i try <code>return $this-&gt;role()-&gt;name;</code> it gives me a:</p>
  
  <p><em>ErrorException in User.php line 38:
  Undefined property: Illuminate\Database\Eloquent\Relations\BelongsTo::$name</em></p>
  
  <p>But i check for role and that works...</p>
  
  <pre><code>/**
   * Check if the user is an admin.
   *
   * @return bool
   */
  public function isAdmin()
  {
      if ($this-&gt;role-&gt;name == 'admin') {
          return true;
      }
  
      return false;
  } 
  </code></pre>