laravel 新增後臺登陸守護器
阿新 • • 發佈:2018-12-27
後臺不能在一個瀏覽器登陸,下面簡單配置下即可解決這個問題。
設定路由如下:
<?php
/**
* 後臺路由,從Illuminate\Routing\Router控制器的auth()方法中複製過來的
*/
Route::namespace('Admin')->group(function () { // Authentication Routes... Route::get('login', 'Auth\[email protected]')->name('admin.login'); Route::post('login', 'Auth\[email protected] '); Route::post('logout', 'Auth\[email protected]')->name('admin.logout'); // Registration Routes... Route::get('register', 'Auth\[email protected]')->name('admin.register'); Route::post('register', 'Auth\[email protected]'); // Password Reset Routes... Route::get('password/reset', 'Auth\ [email protected]')->name('admin.password.request'); Route::post('password/email', 'Auth\[email protected]')->name('admin.password.email'); Route::get('password/reset/{token}', 'Auth\[email protected]')->name('admin.password.reset'); Route::post('password/reset', 'Auth\[email protected] '); Route::middleware(["auth:admin"])->group(function () { Route::get('/', '[email protected]')->name('admin'); }); }); <?php /** * 前臺路由,從Illuminate\Routing\Router控制器的auth()方法中複製過來的 */ Route::get('/', function () { return view('welcome'); }); // Authentication Routes... Route::get('login', 'Auth\[email protected]')->name('login'); Route::post('login', 'Auth\[email protected]'); Route::post('logout', 'Auth\[email protected]')->name('logout'); // Registration Routes... Route::get('register', 'Auth\[email protected]')->