title: Laravel update record where something has been changed
body: <p>I want write method to update records where something has been changed. I have forms:
  <a href="https://i.stack.imgur.com/803f1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/803f1.png" alt="enter image description here"></a></p>
  
  <p>The problem is when I change the name, surname or email but don't change the user login. In my validation I write:</p>
  
  <pre><code>'name' =&gt; ['required', 'max:255', 'unique:users'],
  </code></pre>
  
  <p>But the rule <code>unique:users</code> blocks me from updating when I haven't changed the user name. </p>
  
  <p>I found this theme <a href="https://stackoverflow.com/questions/36329850/laravel-5-isdirty-always-returns-false?answertab=oldest#tab-top">Laravel 5 isDirty() always returns false</a> but I dont understand what is "<code>$partnersData</code>". <code>$partnersData</code> is a date last update ?</p>
  
  <p>I wrote this method:</p>
  
  <pre><code>public function update(CreateUserUpdateRequest $request, $id){
      $user = User::find($id);
  
      foreach ($user as $column =&gt; $value) {
          if ($column === $id) {
              continue;
          }
          $user-&gt;$column = $value;
      }
  
      if ($user-&gt;isDirty()) {
          $user-&gt;update($request-&gt;all());
          Session::flash('userUpdateOK', 'Dane użytkonika zostały zaktualizowane poprawnie.');
      }
  
      return redirect('user');
  }
  </code></pre>