title: Laravel one-to-one relationship not associating
body: <p>I've got two models, Template and State that are associated via a one-to-one relationship. The State belongs to the Template,</p>
  
  <p>A foreign key is created using the following migration:</p>
  
  <pre><code>public function up()
  {
      Schema::table(
          'templates',
          function (Blueprint $table) {
              $table-&gt;dropColumn('state');
  
              $table-&gt;integer('state_id')-&gt;unsigned()-&gt;index()-&gt;nullable();
              $table-&gt;foreign('state_id')-&gt;references('id')-&gt;on('template_states');
          }
      );
  }
  </code></pre>
  
  <p>Then, the Template model class defines the state field as a hasOne relationship:</p>
  
  <pre><code>public function state()
  {
      return $this-&gt;hasOne('TemplateState', 'id', 'state_id');
  }
  </code></pre>
  
  <p>and the TemplateState model class defines the inverse belongs to bit with:</p>
  
  <pre><code>public function template()
  {
      return $this-&gt;belongsTo('Template');
  }
  </code></pre>
  
  <p>I'm having great difficulty associating the state with it's template once created in the DB. Take a look at the following Tinker:</p>
  
  <pre><code>[1] &gt; $t = Template::find(1);
  // object(Template)(
  //   'incrementing' =&gt; true,
  //   'timestamps' =&gt; true,
  //   'exists' =&gt; true
  // )
  [2] &gt; $t-&gt;alias;
  // 'travel_journal'
  [3] &gt; $s = TemplateState::find(1);
  // object(TemplateState)(
  //   'incrementing' =&gt; true,
  //   'timestamps' =&gt; true,
  //   'exists' =&gt; true
  // )
  [4] &gt; $s-&gt;state;
  // 'pending'
  [5] &gt; $t-&gt;state()-&gt;save($s);
  // object(TemplateState)(
  //   'incrementing' =&gt; true,
  //   'timestamps' =&gt; true,
  //   'exists' =&gt; true
  // )
  [6] &gt; $t-&gt;state-&gt;state;
  </code></pre>
  
  <p>At step [6] of the tinker, calling $t->state->state, I can see there's no association made with the two models, and looking in the database, the state_id for the template is still null.</p>
  
  <p>I can't figure out what I'm doing wrong, can anyone please help!</p>