title: how to use required_if validation in Laravel?
body: <p>I really wish to know how am i supposed to use <code>required_if</code> on <code>JSON</code>?</p>
  
  <p>I'm still confused about the idea of API but I have to finish my task, I've added the <code>validation</code> on my controller but it doesn't work.</p>
  
  <pre class="lang-php prettyprint-override"><code>public function StoreReqSchedule(Request $request){
  
      $this-&gt;validate([
          'reqtype'=&gt; 'required',
          'startdate' =&gt; 'required',
          'enddate' =&gt; 'required',
          'reason'=&gt; 'required_if: reqtype,==, Request Day Off',
          'route' =&gt; 'required_if: reqtype,==, Request Schedule',
          'actualschedule' =&gt; 'required_if:reqtype,==, Change Schedule',
          'changetoschedule'=&gt;'required_if:reqtype,==,Change schedule',
          'swapcrewid'=&gt; 'required_if:reqtype,==,Swap Schedule',
          'swapcrewschedule'=&gt;'required_if:reqtype,==,Swap Schedule',
          'note'=&gt;'required'
      ]);
      // ...
  }
  </code></pre>
  
  <p>is this the correct way to use required if?</p>
  
  <p>****EDIT** </p>
  
  <p>Each <code>API endpoint</code> consist of this parameter:</p>
  
  <ol>
  <li><p>For Request Schedule:</p></li>
  <li><p>request-type</p></li>
  <li><p>start-date</p></li>
  <li><p>end-date</p></li>
  <li><p>reason (<strong>Mandatory if request type Request Day Oﬀ</strong>)</p></li>
  <li><p>route (<strong>Mandatory if request type Request Schedule</strong>)</p></li>
  <li><p>actual-schedule (Mandatory if request type Change Schedule)</p></li>
  <li><p>change-to-schedule (Mandatory if request type Change Schedule)</p></li>
  <li><p>swap-crew-id (Mandatory if request type Swap Schedule)</p></li>
  <li><p>swap-crew-schedule (Mandatory if request type Swap Schedule)</p></li>
  <li><p>note</p></li>
  </ol>
  
  <p>those lists above is the task, I'm having difficulties to understand how to write the code for <strong>Mandatory if request type Request Day Oﬀ</strong> and the other mandatory ofc. </p>
  
  <blockquote>
    <p>ErrorException: Declaration of
    App\Http\Controllers\B777Controller::validate($request) should be
    compatible with
    App\Http\Controllers\Controller::validate(Illuminate\Http\Request
    $request, array $rules, array $messages = Array, array
    $customAttributes = Array) >> this is the error</p>
  </blockquote>