title: Laravel HasMany create child record
body: <p>I'm having a problem when I'm trying to create a child model associated to his parent.</p>
  
  <p>I have 2 models:</p>
  
  <ul>
  <li>Instituion (has many addresses)</li>
  <li>Address (has 1 Institution)</li>
  </ul>
  
  <p>When I click a Institution and I go to show.blade.php where I have a form to create an Address for that Institution I can't get from the request the field "instituion_id" which relates child with parent.</p>
  
  <p>This is shown in the request:</p>
  
  <p>Request Data</p>
  
  <p><a href="https://i.stack.imgur.com/uChAb.png" rel="noreferrer"><img src="https://i.stack.imgur.com/uChAb.png" alt="enter image description here"></a></p>
  
  <p>From the form I'm calling the following route: action="/institution/{{ $institution->id }}/addresses"</p>
  
  <p>This is the code in AddressController:</p>
  
  <pre><code>public function store(Request $request)
  {
      // dd($request-&gt;all());
      Address::create($request-&gt;all());
      return back();
  }
  </code></pre>
  
  <p>When I test it, the DB is asking for the isntitution_id column: </p>
  
  <blockquote>
    <p>SQLSTATE[HY000]: General error: 1364 Field 'institution_id' doesn't
    have a default value (SQL: insert into <code>addresses</code> (<code>address_name</code>,
    <code>address_number</code>, <code>address_full_name</code>, <code>address_city</code>,
    <code>address_state</code>, <code>address_postal_code</code>, <code>address_country</code>,
    <code>updated_at</code>, <code>created_at</code>) values (a, a, a, a, a, a, a, 2017-12-14
    14:06:47, 2017-12-14 14:06:47))</p>
  </blockquote>
  
  <p>So, how to I pass from the form the field "institution_id" and how do I get it in the controller and assocuiated to the child record?</p>
  
  <p>I read many posts but in all of them they are just create a child record with one field but I want to process the complere request with all Addres fields.</p>
  
  <p>Regards</p>