i have a query regarding validate() method in laravel 10 how we are able to pass 2nd param to validate method for creating customer validation messages? i cant find anything regarding validate() in laravel 10 official docs where they should have explained the validate() method that whether it takes 2 params or 3 params and what we should pass in them, what should be the syntax. i even checked api docs but those docs are too complex man.I am unable to find validate() method in api docs may be it is getting created dynamically not hardcoded.. hahaha. shame on me but need answer, can someone help?
public function addUser(Request $req){
$validated=$req->validate([
'name'=>'required',
'age'=>'required',
'email'=>'required',
'city'=>'required'
],
[
//2nd param
'name.required'=> 'you name is xyz'
]);
$user = DB::table('meenas')->insert([
'name'=>$req->input('name'),
'age'=>$req->input('age'),
'email'=>$req->input('email'),
'city'=>$req->input('city'),
]);
if($user){
return redirect()->route('showallusers')->with('true','user registered successfully');
}
else{
return redirect()->route('addform')->with('false','Cant register user');
//returb back()->with();
}
}