title: Laravel validation if condition
body: <p>I am trying to validate my field. If is_teacher is false and teacher_id is empty. then i will throw error message. But I am not sure why even if the is_teacher field is true they also prompt this error message. Suppose is_teacher is true, then no need enter this condition.</p>
  <pre><code>if(is_bool($input['is_teacher']) == false &amp;&amp; empty($input['teacher_id'])) {
     $validator-&gt;errors()-&gt;add('teacher_id', 'Please select a teacher.');
     return response()-&gt;json([
        'error'    =&gt; true,
        'messages' =&gt; $validator-&gt;errors(),
     ], 422);
  }
  </code></pre>