title: Laravel - Avoid validation error for unique rule when updating
body: <p>I'm using Laravel 5.3's validation as follows:</p>
  
  <p>In my model:</p>
  
  <pre><code>public static $validation = [
      'name' =&gt; 'required',
      'username' =&gt; 'required|alpha|unique:companies',
      'email' =&gt; 'required|email|unique:companies',
  ];
  </code></pre>
  
  <p>In my controller, I post to the same <code>CompanyController@dataPost</code> method when creating a new item or when editing one:</p>
  
  <pre><code>public function dataPost(Request $request) {
  
      // First validation
      $this-&gt;validate($request, Company::$validation);
  
      $id = $request-&gt;id;
  
      if ($id &gt; 0) {
          // Is an edit!
          $company = Company::find($id);
          $company-&gt;update($request-&gt;all());
          $company-&gt;save();
  
          Session::flash('messageclass', 'success');
          Session::flash('message', trans('companies.editedsuccessfully'));
  
      } else {
          // Is a create
          $company = new Company($request-&gt;all());
          $company-&gt;save();
  
          Session::flash('messageclass', 'success');
          Session::flash('message', trans('companies.createdsuccessfully'));
      }
  
      return redirect()-&gt;route('companyindex');
  }
  </code></pre>
  
  <p>The unique validation works ok when I create a new item, but causes an error (as in it flags the username as already existing) when editing an item.</p>
  
  <p>Any idea how to avoid this? Even in an edit I'd still want to ensure the data is unique if it's changed, but if the value is the same as before then ignore the validation.</p>
  
  <p>I know I could do this manually, but I wonder if there is a built-in way to avoid this.</p>
  
  <p>Thanks!</p>