public function login(Request $request) { $info = Validator::make($request->all(), [ ‘username‘ => ‘required‘, ‘password‘ => ‘required‘, ],[ ‘username.required‘ => ‘用户名必须填写‘, ‘password.required‘ => ‘密码必须填写‘, ]); if ($info->fails()) { //返回json数据 return response()->json([‘code‘=>"201","msg"=>$info->errors()->first()]); } // dd($info->errors()->first()); // return $info; }
原文地址:https://www.cnblogs.com/zjj1990/p/11721170.html
时间: 2024-11-14 12:51:03