我在Laravel建立一個應用程序,我已經有我的用戶註冊工作正常,我現在想修改註冊如何工作,所以我修改我的路線來調用不同的方法。Laravel post路由控制器方法沒有被調用
原來的路線的定義,像這樣:
Route::post('register', 'Auth\[email protected]');
這工作得很好。然後,我把它改爲:
Route::post('register', 'Auth\[email protected]');
此方法定義如下:
public function someOtherMethod(Request $request)
{
die('If the method is called you should see this');
}
然而,它不會被調用(該消息未顯示)。相反,它會將我重定向到網站的根目錄。
請注意,我有我的服務器,我跑我每次有這樣奇怪的問題時,其運行以下命令的緩存清除腳本:在隱身
php artisan route:clear
php artisan cache:clear
service php5-fpm restart
service nginx restart
我也跑了頁/私有每次我做出改變時都會出現窗口。
現在有趣的部分;我試着撤銷我所做的更改,以便再次調用postRegister
,我完全期望這會使其恢復爲默認行爲,但仍會將我重定向到網站的根目錄!所以現在我甚至沒有註冊頁面。
有沒有人有任何想法是怎麼回事?
在此先感謝您的幫助。
編輯:
這裏是我的全routes.php
:
use Illuminate\Http\Request;
Route::group(['middleware' => 'web'], function() {
/** Public routes **/
Route::get('', '[email protected]');
Route::get('/', '[email protected]');
Route::get('terms', function() {
return view('terms');
});
Route::get('privacy', function() {
return view('privacy');
});
/** Public auth routes **/
Route::get('register', 'Registr[email protected]');
Route::post('register', 'Auth\[email protected]');
Route::get('login', function() {
return view('auth.login');
});
Route::post('login', 'Auth\[email protected]');
Route::get('logout', 'Auth\[email protected]');
Route::get('dashboard/login', function() {
return view('admin.login');
});
Route::post('dashboard/login', 'AdminAuth\[email protected]');
Route::get('dashboard/logout', 'AdminAuth\[email protected]');
/** Admin routes **/
Route::get('dashboard', [
'middleware' => 'admin',
'uses' => 'Admin\[email protected]'
]);
Route::get('dashboard/users', [
'middleware' => 'admin',
'uses' => 'Admin\[email protected]'
]);
Route::get('dashboard/search', [
'middleware' => 'admin',
'as' => 'adminSearch',
'uses' => 'Admin\[email protected]'
]);
/** Admin auth routes **/
Route::get('dashboard/staff/create', [
'middleware' => 'admin',
function() {
return view('admin.register');
}
]);
Route::post('dashboard/staff/create', [
'middleware' => 'admin',
'uses' => 'AdminAuth\[email protected]'
]);
/** Controllers **/
Route::controllers([
'password' => 'Auth\PasswordController',
]);
});
擊中你的註銷網址一次,然後再試一次? –
是的,我也是這麼做的。此外,正如我所提到的,每當我嘗試這樣做時都會打開一個新的隱身/私人窗口,因此登錄不應該成爲問題。 –
你在哪裏放置這條路線?在'web'中間件之外。對? –