title: Duplicate function update
body: <p>I am trying to create a duplicate system, I have a form revision with a recording.</p>
  
  <p>For example, I have to change the value of my field hour_start => 18:00</p>
  
  <p><a href="https://i.stack.imgur.com/HTZ7e.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HTZ7e.png" alt="enter image description here"></a></p>
  
  <p>I want to replace by the value => 08:00</p>
  
  <p><a href="https://i.stack.imgur.com/CxnHI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CxnHI.png" alt="enter image description here"></a></p>
  
  <p>When, I validate the form I have an error message: </p>
  
  <p><a href="https://i.stack.imgur.com/cglQr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cglQr.png" alt="enter image description here"></a></p>
  
  <p>The value of my field hour start is always the same</p>
  
  <p><a href="https://i.stack.imgur.com/2JhOF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2JhOF.png" alt="enter image description here"></a></p>
  
  <p>In fact, my duplicate system must work for dates, but if I change a value of my field hour_start, it must pass...</p>
  
  <pre><code>public function update(revisionRequest $request, $id)
      {
  
          $exists = Revision::where('date_revision_start', $request-&gt;get('date_revision_start'))-&gt;where('date_revision_end', $request-&gt;get('date_revision_end'))-&gt;where('hour_start', $request-&gt;get('hour_start'))-&gt;where('hour_end', $request-&gt;get('hour_end'))-&gt;where('fk_motorbike', $request-&gt;get('fk_motorbike'))-&gt;where('fk_garage', $request-&gt;get('fk_garage'))-&gt;count();
  
          $date_revision_start = $request-&gt;get('date_revision_start');
          $date_revision_end = $request-&gt;get('date_revision_end');
  
          $conflict = Revision::where('fk_motorbike', $request-&gt;get('fk_motorbike'))-&gt;whereDate('date_revision_start', "&lt;=" , $date_revision_start)
              -&gt;whereDate('date_revision_end', "&gt;=", $date_revision_start)
              -&gt;first();
  
          $conflict2 = Revision::where('fk_motorbike', $request-&gt;get('fk_motorbike'))-&gt;whereDate('date_revision_start', "&lt;=" , $date_revision_end)-&gt;whereDate('date_revision_end', "&gt;=", $date_revision_end)-&gt;first();
  
          if(isset($conflict2) || isset($conflict)){
              return redirect()-&gt;route('revisions.index')
               -&gt;with('error', 'Duplicate date! ');
          }
  
  
          else{
              $revisions = Revision::find($id);
              $revisions-&gt;date_revision_start = $request-&gt;get('date_revision_start');
              $revisions-&gt;date_revision_end = $request-&gt;get('date_revision_end');
              $revisions-&gt;hour_start = $request-&gt;get('hour_start');
              $revisions-&gt;hour_end = $request-&gt;get('hour_end');
              $revisions-&gt;fk_garage = $request-&gt;get('fk_garage');
              $revisions-&gt;fk_motorbike = $request-&gt;get('fk_motorbike');
              $revisions-&gt;save();
              return redirect()-&gt;route('revisions.index')
                      -&gt;with('success', 'ok')-&gt;withInput();
          }
  
      } 
  </code></pre>
  
  <p>Thank you for your help.</p>
  
  <p><strong>Edit</strong>:@Watercayman </p>
  
  <p>I test this:</p>
  
  <pre><code>if( (isset($conflict2) &amp;&amp; $conflict2-&gt;id !== $id)
          || (isset($conflict) &amp;&amp; $conflict-&gt;id !== $id) ){
              return redirect()-&gt;route('entretiens.index')
               -&gt;with('error', 'Duplicate date! ');
          }
  
          @dd($conflict-&gt;id);
  </code></pre>