【发布时间】:2020-02-27 20:07:14
【问题描述】:
我正在使用 laravel 6 并且在我的应用中有 2 条路线;索引和仪表板。
我的routes/web 是:
Auth::routes();
Route::middleware(['auth'])->group(function () {
Route::get('/index', 'todoApp\TodoController@index')->name('index');
Route::get('/dashboard', 'todoApp\Dashboard@dashboard')->name('dashboard');
});
我最近添加了仪表板路线。
当我将Auth::user() 转储到仪表板路由但不在索引中时,Auth::user() 为空。这是什么
【问题讨论】:
-
您在 Dashboard Controller 中将
Auth::user()称为哪里?? -
在
__construct和dashboard方法中 -
写入你的控制器。公共函数 __construct() { $this->middleware('auth'); }
标签: laravel authentication laravel-routing