gpt4 book ai didi

php - Illuminate\Routing\Route 类的对象无法转换为 int

转载 作者:可可西里 更新时间:2023-10-31 23:28:54 25 4
gpt4 key购买 nike

我有这样的路线:

Route::post('login', [
'uses' => 'AuthController@postLogin',
'before' => 'guest'
]);

但它不起作用,我只收到错误消息:“类 Illuminate\Routing\Route 的对象无法转换为 int”

我不知道我做错了什么。

我的路线:

Route::group(['middleware' => ['auth, guest']], function () { 
Route::get('/', array('as' => 'home', 'uses' => 'HomeController@getIndex'));
Route::get('/login', array('as' => 'login', 'uses' => 'AuthController@getLogin')) -
Route::post('login', [ 'uses' => 'AuthController@postLogin', 'before' => 'guest', ]);
});

授权 Controller

public function postLogin() { 

$rules = array('username' => 'required', 'password' => 'required');
$validator = Validator::make(Input::all(), $rules);

if ($validator->fails()) {

return Redirect::route('login')->withErrors($validator);
}

$auth = Auth::attempt(array( 'name' => Input::get('username'), 'password' => Input::get('password'), ), false);

if (!$auth) {
return Redirect::route('login')->withErrors(array( 'Invalid credentials were provided', ));

}
return Redirect::route('home');

}

最佳答案

我能够重现您遇到的错误。

您的路线有错别字。 (修复第一行的分号。)

改变这个:

Route::get('/login', array('as' => 'login', 'uses' => 'AuthController@getLogin'))-

Route::post('login', [
'uses' => 'AuthController@postLogin',
'before' => 'guest',
]);

收件人:

Route::get('/login', array('as' => 'login', 'uses' => 'AuthController@getLogin'));

Route::post('login', [
'uses' => 'AuthController@postLogin',
'before' => 'guest'
]);

关于php - Illuminate\Routing\Route 类的对象无法转换为 int,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35514151/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com