title: Conditional validation if checkbox selected laravel
body: <p>I have a form in Laravel in which I want to validate three text fields based on a checkbox. Its an edit user form in which I only want to update the password if I select yes. This is the form in my view:</p>
  <pre><code>&lt;section&gt;
      &lt;div class=&quot;form&quot;&gt;
          &lt;h1&gt;Edit: {!! $user-&gt;name !!}&lt;/h1&gt;
          {!! Form::model($user, ['method' =&gt; 'PATCH', 'action' =&gt; ['AccountController@update', $user-&gt;id], 'files' =&gt; true]) !!}
          &lt;p&gt;Name: {!! Form::text('name') !!}
          &lt;p&gt;Email: {!! Form::text('email') !!}
          &lt;p&gt;Update Password? (tick for yes) &amp;nbsp; {!! Form::checkbox('updatepasswordcheck', 0, false) !!}
          &lt;p&gt;Old Password: {!! Form::password('oldpassword') !!} 
          &lt;p&gt;New Password: {!! Form::password('newpassword') !!}
          &lt;p&gt;New Password Confirm: {!! Form::password('newpasswordconfirm') !!}
          @if($user-&gt;role_id == 1) 
              &lt;p&gt;User Role: {!! Form::select('user_type', ['admin', 'guest'], '1') !!}
          @else
              &lt;p&gt; User Role: {!! Form::select('user_type', ['admin', 'guest'], '0') !!}
          @endif
          &lt;p&gt;{!! Form::submit('Update') !!}
          {!! Form::close() !!}
          @include ('errors.list_errors')
      &lt;/div&gt;
  &lt;/section&gt;
  </code></pre>
  <p>I then have a request called EditAccountRequest like so:</p>
  <pre><code>&lt;?php
  
  namespace App\Http\Requests;
  
  use App\Http\Requests\Request;
  
  class EditAccountRequest extends Request
  {
      /**
       * Determine if the user is authorized to make this request.
       *
       * @return bool
       */
      public function authorize()
      {
          return true;
      }
  
      /**
       * Get the validation rules that apply to the request.
       *
       * @return array
       */
      public function rules()
      {
        
  
          if($this-&gt;inputs['updatepasswordcheck'])
          {
              $rules['oldpassword'] = 'required';
              $rules['newpassword'] = 'required';
              $rules['newpasswordconfirm'] = 'required';  
          }
          $rules['name'] = 'required|min:3';
          $rules['email'] = 'required|email';
          
          return $rules;
      }
  }
  </code></pre>
  <p>My problem is that when I see if the checkbox 'updatepasswordcheck' is true it never works because the input always appears as null. Anyone know how to fix this?</p>