admin管理员组文章数量:1402415
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();
}
}
本文标签: validate() method in laravel 10 can be used for custom validation errors but howStack Overflow
版权声明:本文标题:validate() method in laravel 10 can be used for custom validation errors but how? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744348549a2601911.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论