New LoginRequest
class LoginRequest extends Request
{
public function authorize()
{
return false;
}
public function rules()
{
return [
"username" => "required",
"password" => "required",
"captcha" => "required|captcha"
];
}
public function messages()
{
return [
"username.required" => "!",
"password.required" => "!",
"captcha.required" => "!",
"captcha.captcha" => "!"
];
}
}
how to apply in LoginController controller?
class LoginController extends CommonController
{
public function login(LoginRequest $request)
{
if ($request->isMethod("post")){
$input = $request->all();
$user = User::first();
if ($user->username == $input["username"] && Crypt::decrypt($user->password) == $input["password"]){
$request->session()->put("username", $input["username"]);
return \redirect()->action("Admin\IndexController@index");
}else{
// $validator->errors()->add("errors", "!");
return Redirect::back()->withErrors($validator);
}
}else{
return view("Admin/login");
}
}
}
report a redirection error in this way