Framework: Laravel 5.7.27 (PHP 7.2.10 )
There are several methods in which validation is performed on the server through the explicit designation of the request class: public function store(PostRequest $request)
The PostRequest.php file PostRequest.php validation rules:
public function rules() { return [ 'title' => 'required|min:10', 'text' => 'required|min:10', 'image' => 'required|file|image', ]; } In all cases, image validation is required rule, but in one method it is not needed, how can I prevent it?
rulesimmediately in the model, then the PostRequest object itself is available to you. Check out something from him. I understand that he should have anid. Depending on the presence ofidreturn one or another array of rules. - u_mulder 2:53 pm