title: Laravel Eloquent relationship mapping issue with three tables and belongsTo() function
body: <p>I have three tables (instances, users, user_instance).  Each user can be assigned to one instance.  A instance can have many different users.</p>
  
  <p>I try to get the instance_id of from the instance a particular user is assigned to by using Laravel 5.1 Eloquent and belongsTo() function, by calling $this->user->instance->instance_id.</p>
  
  <p>No matter what I've tried, I'm always getting a NULL result in my AuthController.php:</p>
  
  <p><strong>DB Schema:</strong></p>
  
  <pre><code>    mysql&gt; show columns from instances;
      +------------+------------------+------+-----+---------+----------------+
      | Field      | Type             | Null | Key | Default | Extra          |
      +------------+------------------+------+-----+---------+----------------+
      | id         | int(10) unsigned | NO   | PRI | NULL    | auto_increment |
      | name       | varchar(150)     | NO   |     | NULL    |                |
      | key        | varchar(150)     | NO   |     | NULL    |                |
      | created_at | int(11)          | NO   |     | NULL    |                |
      | updated_at | int(11)          | NO   |     | NULL    |                |
      +------------+------------------+------+-----+---------+----------------+
  
      mysql&gt; show columns from users;
      +----------------+---------------------+------+-----+---------+----------------+
      | Field          | Type                | Null | Key | Default | Extra          |
      +----------------+---------------------+------+-----+---------+----------------+
      | id             | int(10) unsigned    | NO   | PRI | NULL    | auto_increment |
      | first_name     | varchar(50)         | YES  |     | NULL    |                |
      | last_name      | varchar(50)         | YES  |     | NULL    |                |
      | email          | varchar(100)        | NO   |     | NULL    |                |
      | password       | varchar(255)        | NO   |     | NULL    |                |
      | salt           | varchar(255)        | YES  |     | NULL    |                |
      | remember_token | varchar(255)        | YES  |     | NULL    |                |
      | created_at     | int(10) unsigned    | NO   |     | NULL    |                |
      | updated_at     | int(10)             | NO   |     | NULL    |                |
      | last_login     | int(10) unsigned    | YES  |     | NULL    |                |
      | ip_address     | varchar(15)         | NO   |     | NULL    |                |
      | timezone       | int(10)             | YES  |     | NULL    |                |
      | active         | tinyint(1) unsigned | YES  |     | NULL    |                |
      +----------------+---------------------+------+-----+---------+----------------+
  
      mysql&gt; show columns from user_instance;
      +-------------+------------------+------+-----+---------+----------------+
      | Field       | Type             | Null | Key | Default | Extra          |
      +-------------+------------------+------+-----+---------+----------------+
      | id          | int(10) unsigned | YES  | PRI | NULL    | auto_increment |
      | user_id     | int(10) unsigned | NO   |     | NULL    |                |
      | instance_id | int(10) unsigned | NO   |     | NULL    |                |
      | created_at  | int(11)          | NO   |     | NULL    |                |
      | updated_at  | int(11)          | NO   |     | NULL    |                |
      +-------------+------------------+------+-----+---------+----------------+
  </code></pre>
  
  <p><strong>App/Controllers/AuthController.php</strong></p>
  
  <pre><code>    &lt;?php
      use App\Models\User;
      use App\Models\Instance;
      use App\Models\User_Instance;
      class AuthController extends Controller {
      ...
      die($this-&gt;user-&gt;instance); // Returns: NULL
      ...
      }
      ?&gt;
  </code></pre>
  
  <p><strong>App/Models/Instance.php</strong></p>
  
  <pre><code>    &lt;?php namespace App\Models;
  
      use Illuminate\Database\Eloquent\Model;
  
      class Instance extends Model
      {
          /**
           * Indicates if the model should be timestamped.
           *
           * @var bool
           */
          public $timestamps = true;
  
          /**
           * The database table used by the model.
           *
           * @var string
           */
          protected $table = 'instances';
  
          /**
           * The tables primary key.
           *
           * @var string
           */
          protected $primaryKey = 'id';
  
          /**
           * The attributes that are mass assignable.
           *
           * @var array
           */
          protected $fillable = ['name', 'key', 'created_at', 'updated_at'];
  
          /**
           * The attributes excluded from the model's JSON form.
           *
           * @var array
           */
          protected $hidden = [];
      }
      ?&gt;
  </code></pre>
  
  <p><strong>App/Models/User_Instance.php</strong></p>
  
  <pre><code>    &lt;?php namespace App\Models;
  
      use Illuminate\Database\Eloquent\Model;
  
      class User_Instance extends Model
      {
          /**
           * Indicates if the model should be timestamped.
           *
           * @var bool
           */
          public $timestamps = true;
  
          /**
           * The database table used by the model.
           *
           * @var string
           */
          protected $table = 'user_instance';
  
          /**
           * The tables primary key.
           *
           * @var string
           */
          protected $primaryKey = 'id';
  
          /**
           * The attributes that are mass assignable.
           *
           * @var array
           */
          protected $fillable = ['user_id', 'instance_id', 'created_at', 'updated_at'];
  
          /**
           * The attributes excluded from the model's JSON form.
           *
           * @var array
           */
          protected $hidden = [];
      }
      ?&gt;
  </code></pre>
  
  <p><strong>App/Models/User.php</strong></p>
  
  <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;
      use Zizaco\Entrust\Traits\EntrustUserTrait;
  
      class User extends Model implements AuthenticatableContract, CanResetPasswordContract
      {
          use Authenticatable, CanResetPassword, EntrustUserTrait;
  
          /**
           * Indicates if the model should be timestamped.
           *
           * @var bool
           */
          public $timestamps = true;
  
          /**
           * The database table used by the model.
           *
           * @var string
           */
          protected $table = 'users';
  
          /**
           * The tables primary key.
           *
           * @var string
           */
          protected $primaryKey = 'id';
  
          /**
           * The attributes that are mass assignable.
           *
           * @var array
           */
          protected $fillable = [
              'first_name',
              'last_name',
              'email',
              'password',
              'salt',
              'remember_token',
              'created_at',
              'updated_at',
              'last_login',
              'ip_address',
              'timezone',
              'active'
              ];
  
          /**
           * The attributes excluded from the model's JSON form.
           *
           * @var array
           */
          protected $hidden = ['password', 'remember_token'];
  
          /**
           * Map the instance with the user.
           *
           * @var int
           */
          public function instance()
          {
              return $this-&gt;belongsTo('App\Models\User_Instance');
          }
      }
      ?&gt;
  </code></pre>