Answer the question
In order to leave comments, you need to log in
How to use Rule class in laravel?
public function store(Request $request){
...
if ($data['boolean_field']) {
$validator = Validator::make($request->all(), [
'field1' => 'required|integer',
]);
} else {
$validator = Validator::make($request->all(), [
'field2' => 'required|integer',
]);
}
...
}
protected function validator($data)
{
return Validator::make($data, [
...
'field1' => ['required|integer', Rule::boolean('boolean_field',true)], // моя попытка
...
]);
}
Answer the question
In order to leave comments, you need to log in
$rules = [
'field1' => ['required_if:boolean_field,true', 'integer'],
'field2' => ['required_unless:boolean_field,true', 'integer'],
];
Have you tried searching, for example, jQuery slider. There are already a lot of these solutions. For example, I use Nivo Slider
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question