$validator=\Validator::make($request->all(),[ 'username'=>'required', 'password'=>'required', ]); if ($validator->fails()){ return ['code'=>500,'msg'=>$validator->errors()->first()]; }