Answers for "laravel Call to a member function validate() on array"

PHP
0

laravel Call to a member function validate() on array

//I see your problem It is because you are calling validate on array $data

return $data->validate([
                    'LieferNr' => ['required', 'min:5', 'max:5'],
                    'Produkt' => ['required'],
                    'PH' => ['required', 'numeric', "min:$PHmin", "max:$PHmax"],
                    'Wasser' => "required|numeric|min:$Wassermin|max:$Wassermax",
                    'Dichte' => "required|numeric|min:$Dichtemin|max:$Dichtemax",
                    'Bearbeiter' => ['required'],
                ]);

//Instead, do following

use Illuminate\Support\Facades\Validator;
$validator = Validator::make($data, [
                    'LieferNr' => ['required', 'min:5', 'max:5'],
                    'Produkt' => ['required'],
                    'PH' => ['required', 'numeric', "min:$PHmin", "max:$PHmax"],
                    'Wasser' => "required|numeric|min:$Wassermin|max:$Wassermax",
                    'Dichte' => "required|numeric|min:$Dichtemin|max:$Dichtemax",
                    'Bearbeiter' => ['required'],
                ]);

if($validator->fails()){
 return 0;
}
Posted by: Guest on May-09-2022

Code answers related to "laravel Call to a member function validate() on array"

Browse Popular Code Answers by Language