title: laravel mass assignment on set attribute and except column
body: <p>There is a "full_name" column in my database, but there are no "first_name" and "last_name" columns in my database.</p>
  
  <p>This is my form:</p>
  
  <pre><code>&lt;form method="POST" action=""&gt;
      &lt;input type="text" name="first_name"&gt;
      &lt;input type="text" name="last_name"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>This is my model:</p>
  
  <pre><code>class User extends Model
  {
      protected $guarded = ['first_name', 'last_name'];
  
      public function setFullNameAttribute()
      {
          $this-&gt;attributes['full_name'] = $this-&gt;attributes['first_name'].' '.$this-&gt;attributes['last_name'];
      }
  }
  </code></pre>
  
  <p>This is code in my controller Class</p>
  
  <pre><code>public function store(StoreUser $request)
  {
      $validated = $request-&gt;validated();
      $user = Auth::user();
      $user-&gt;update($validated);
  }
  </code></pre>
  
  <hr>
  
  <p>After I submit form, there is an error:</p>
  
  <pre><code>SQLSTATE[42S22]: Column not found: 1054 Unknown column 'first_name' in 'field list'
  </code></pre>
  
  <p>I know what Cause this, is because <code>$guarded = ['first_name', 'last_name']</code></p>
  
  <p>But if I didn't guarded those fields, there is an error:</p>
  
  <pre><code>"Undefined index: first_name"
  </code></pre>
  
  <p>I know what cause this, is because there is no "first_name" column in my database.</p>
  
  <hr>
  
  <blockquote>
    <p>So I get stuck and don't know how to update "full_name" into database,
    and prevent assign "first_name" and "last_name" fields.</p>
  </blockquote>
  
  <p>PS, I don't use <code>$user-&gt;save()</code> is because there are mass assignment need to update in real world.</p>