我正在尝试使用laravel创建自定义检查。我在LoginController
public function customchecker()
{
$credentials = [
'username' => Input::get('username'),
'password' => Input::get('password')
];
if (Auth::attempt($credentials)) {
return Redirect::to('account')->with('alert-success', 'You are now logged in.');
$errors = new MessageBag(['password' => ['Email and/or password invalid.']]);
return Redirect::back()->withErrors($errors)->withInput(Input::except('password'));
}
}
这是我的路线
Route::get('/', function () {
return view('welcome');
});
Auth::routes();
Route::get('/home', 'HomeController@index')->name('home');
Route::get('customchecker','LoginController@customchecker')->name('customchecker');
但我收到错误,这是我的错误
Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException 没有消息
所以,我该如何解决这个问题?
答案 0 :(得分:1)
您的customchecker
路由被声明为GET
,请确保您使用相同的操作,而不是POST
或其他。