title: Laravel 5.2 set model attributes based on fields in Input
body: <p>I have huge user update form. Sometimes update contains huge amount of fields, sometimes just one or two. This is my code:</p>
  
  <pre><code>public function updateUser(Request $request){
      $user = User::where('id',$request-&gt;id)-&gt;firstOrFail();
  
      if($request-&gt;first_name){
          $user-&gt;first_name= $request-&gt;first_name;
      }
  
      if($request-&gt;last_name){
          $user-&gt;last_name = $request-&gt;last_name;
      }
  
      if($request-&gt;job_name){
          $user-&gt;job_name= $request-&gt;job_name;
      }
  
      //etc.. 20 more fields
  
      $user-&gt;save();
  </code></pre>
  
  <p>It is possible to set model attributes dependent on fields in <code>$request</code>? Sometimes <code>$request</code> contains 1 field, sometimes 20. Please notice I want to <strong>touch database only once</strong>, using save() method at the end.</p>