title: Laravel validation 'unique' not working as expected
body: <p>I'm developing a Help Centre for a site and I've asked the question over at the <a href="https://laracasts.com/discuss/channels/requests/validation-unique-not-working-as-expected/edit" rel="nofollow">Laracast Forums</a> to which I haven't had a solution from yet unfortunately, here us the routes/url paths for it:</p>
  
  <p><strong>routes.php</strong></p>
  
  <pre><code>Route::resource('admin/help-centre/category', 'AdminHelpCentreCategoryController');
  Route::resource('admin/help-centre/category/{category}/section', 'AdminHelpCentreSectionController');
  Route::resource('admin/help-centre/category/{category}/section/{section}/article', 'AdminHelpCentreArticleController');
  </code></pre>
  
  <p>Category and Section validation are working as expected, but for some reason even though it's the same logic, as far as I can tell, the Article validation doesn't seem to work as expected. Here are my validation rules (I've removed the excess and just left the title field):</p>
  
  <p><strong>HelpCentreCategoryRequest.php</strong></p>
  
  <pre><code>/* Insert ------------------------------------- */
      $rules = [
          'title' =&gt; 'required|min:3|unique:help_centre_categories',
      ];
  
  /* Update ------------------------------------- */
      if ($method == 'PATCH') {
  
          $rules = [
              'title' =&gt; 'required|min:3|unique:help_centre_categories,title,'.$this-&gt;category-&gt;id,
          ];
  
      }
  </code></pre>
  
  <p><strong>HelpCentreSectionRequest.php</strong></p>
  
  <pre><code>/* Insert ------------------------------------- */
      $rules = [
          'title' =&gt; 'required|min:3|unique:help_centre_sections,title,NULL,id,category_id,'.$this-&gt;category-&gt;id,
      ];
  
  
  /* Update ------------------------------------- */
      if ($method == 'PATCH') {
  
          $rules = [
              'title' =&gt; 'required|min:3|unique:help_centre_sections,title,'.$this-&gt;section-&gt;id.',id,category_id,'.$this-&gt;category-&gt;id,
          ];
  
      }
  </code></pre>
  
  <p>I'll explain just to clarify... for Categories, on <code>INSERT</code> it checks to see if that title already exists, if it does, it doesn't validate. <code>UPDATE</code> does exactly the same except it ignores itself in the check so it can still validate if the title hasn't been changed. So I entered 2 Categories, one called <code>Category 1</code> and the other <code>Category 2</code>.</p>
  
  <p>Same goes for the Section request, except it only checks for Sections which are in the specified Category you're creating it in. I've tested this out and it works. I can insert <code>foo</code> and <code>bar</code> into <code>Category 1</code> and <code>foo</code> and <code>bar</code> into <code>Category 2</code>, but if I try to add another <code>foo</code> into either <code>Category 1</code> or <code>Category 2</code>, it doesn't validate cause it's a duplicate, which is correct. But if I try to update <code>foo</code> in <code>Category 1</code> to <code>bar</code> it won't allow it, and also if I try to update <code>foo</code> without making any changes, it ignores itself (row) allowing it to pass and not throw a validation error. So everything works as it should for this.</p>
  
  <p>Now for my Article validation, I've used the exact same process/query validation as the Section validation, except changing table/column/variables to suit, like this:</p>
  
  <p><strong>HelpCentreArticleRequest.php</strong></p>
  
  <pre><code>/* Insert ------------------------------------- */
      $rules = [
          'title' =&gt; 'required|min:3|unique:help_centre_articles,title,NULL,id,section_id,'.$this-&gt;section-&gt;id,
      ];
  
  
  /* Update ------------------------------------- */
      if ($method == 'PATCH') {
  
          $rules = [
              'title' =&gt; 'required|min:3|unique:help_centre_articles,title,'.$this-&gt;article-&gt;id.',id,section_id,'.$this-&gt;section-&gt;id,
          ];
  
      }
  </code></pre>
  
  <p>This should do exactly the same as <code>HelpCentreSectionRequest.php</code>, so allow only one copy of an Article title in each Section of a Category, while allowing an Article of the same title but in a different Section of a Category. That part works fine, however if I insert <code>foo</code> and <code>bar</code> in <code>Category 1 / Section 1</code>, and then update <code>foo</code> to <code>bar</code> it allows the change and to me, it shouldn't since <code>bar</code> already exists in <code>Category 1 / Section 1</code>.</p>
  
  <p>I'm obviously wrong though or else it would work as I expected it too ha. But I just can't see what the problem is?</p>
  
  <p>Here is the database schema just to save any hassle and can confirm table/column names match (again with foreign keys and extra columns removed):</p>
  
  <pre><code>Schema::create('help_centre_categories', function(Blueprint $table)
  {
      $table-&gt;increments('id')-&gt;unsigned();
      $table-&gt;string('title');
  });
  
  Schema::create('help_centre_sections', function(Blueprint $table)
  {
      $table-&gt;increments('id')-&gt;unsigned();
      $table-&gt;integer('category_id')-&gt;unsigned();
      $table-&gt;string('title');
  });
  
  Schema::create('help_centre_articles', function(Blueprint $table)
  {
      $table-&gt;increments('id')-&gt;unsigned();
      $table-&gt;integer('category_id')-&gt;unsigned();
      $table-&gt;integer('section_id')-&gt;unsigned();
      $table-&gt;string('title');
  });
  </code></pre>
  
  <p>I've also checked the <code>if</code> statement in the Article request is definitely firing which was mentioned in the Laracast Forum link at the top. You can also find the Valiation docs <a href="http://laravel.com/docs/5.0/validation" rel="nofollow">here</a>, but for easy reading, this is the main section I am using:</p>
  
  <pre><code>Adding Additional Where Clauses
  
  You may also specify more conditions that will be added as "where" clauses to the query:
  
  'email' =&gt; 'unique:users,email_address,NULL,id,account_id,1'
  
  In the rule above, only rows with an account_id of 1 would be included in the unique check.
  </code></pre>