主要参考
https://blog.csdn.net/realghost/article/details/52512268
https://blog.csdn.net/greatyoulv/article/details/80261656
https://blog.csdn.net/weixin_43814458/article/details/105203628
https://blog.csdn.net/weixin_43814458/article/details/105203628
https://blog.csdn.net/lzh2018/article/details/102601354
中间产生的问题
报错
1 Auth guard [admin] is not defined.
检查 配置文件 guard 中的 admin 名称正确,清下 配置缓存 试试
执行
php artisan config:clear
php artisan clear-compiled
2 编辑admin中间件,app\Http\Middleware\AuthAdmin.php
(详见app\Http\Kernel.php中的protected $routeMiddleware)
public function handle($request, Closure $next, $guard)
{
if(!Auth::guard($guard)->check())
{
return redirect('admin/login');
}
return $next($request);
}
3 分别 退出登录
public function logout(Request $request)
{
$this->guard()->logout();
$request->session()->forget($this->guard()->getName());
$request->session()->regenerate();
return redirect('admin/login');
}