Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

IlluminateValidationRulesRequiredIf

use IlluminateSupportFacadesValidator;
    use IlluminateValidationRule;
    
    Validator::make($request->all(), [
        'role_id' => Rule::requiredIf($request->user()->is_admin),
    ]);
    
    Validator::make($request->all(), [
        'role_id' => Rule::requiredIf(function () use ($request) {
            return $request->user()->is_admin;
        }),
    ]);
Source by stackflow.cc #
 
PREVIOUS NEXT
Tagged: #IlluminateValidationRulesRequiredIf
ADD COMMENT
Topic
Name
1+5 =