If your validation rules depend on some condition, you can modify the rules by adding withValidator()
to your FormRequest
class, and specify your custom logic there. Like, if you want to add validation rule only for some user role.
1use Illuminate\Validation\Validator;2class StoreBlogCategoryRequest extends FormRequest {3 public function withValidator(Validator $validator) {4 if (auth()->user()->is_admin) {5 $validator->addRules(['some_secret_password' => 'required']);6 }7 }8}