Answer the question
In order to leave comments, you need to log in
How to make image validation work in Laravel FormRequest?
There is a FormRequest created with the name ModelRequest, it has rules for validating images when creating a model
protected $rules = [
'image_primary' => 'required|image',
'image_secondary' => 'nullable|image'
];
public function rules() {
return $this->rules;
}
class ModelUpdateRequest extends ModelRequest{
public function rules() {
$this->rules['image_primary'] = 'nullable|image';
return $this->rules;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question