title: updating related tables from a controller laravel
body: <p>Hi I’ve a users and education table. A user can have multiple school or college. So its one to many relationship. education table has <code>school</code>, <code>from_year</code>, <code>to_year</code>  and <code>user_id (fk)</code>  I want to update the user table as well as education table from a PUT request to <code>users/{id}</code> with <code>email</code>,<code>school</code>, <code>from_year</code>, and <code>to_year</code> fields.</p>
  
  <pre><code>// UsersController.php
  
     public function update(Request $request, $id)
      {
          $user = User::find($id);
          if (!$user) {
              return $this-&gt;respondNotFound('User not found');
          }
          $input = $request-&gt;all();
          $input = array_filter($input, 'strlen');
          //$user-&gt;update($input);
          //Get array of school records
          // $user-&gt;educatoion-&gt;push($records) // don't know what will come here to update the education table
          // or may be $user-&gt;push(); // don't know
          return $this-&gt;respond([
              'data' =&gt; $user,
          ]);
      }
  </code></pre>