我试图在登录后将用户发送到不同的页面。所以我使用 laravel jetstream 。但我不希望将用户发送到仪表板。所以在routeserviceprovider中我写了 public const HOME = 'home';但登录后它仍然将我发送到仪表板。我希望用户转到 home.index 。我认为问题出在routeserviceprovider.php 上。但不知道它是什么。我已经尝试解决这个问题超过 5 个小时了。
我也尝试过 php artisan 优化:clear
这是 RouteServiceProvider.php 的代码
public const HOME = 'home';
这是我的路线
route::get('/home',[AdminController::class,'home']);
这是我的控制器代码
public function home()
{
if(Auth::id())
{
$usertype = Auth()->user()->usertype;
if($usertype == 'user')
{
return view('home.index');
}
else
{
return view('admin.index');
}
}
else
{
return redirect()->back();
}
}
在 config 文件夹中你会发现一个 fortify.php 文件 更改 'home' => '/home' 的值 这将解决你的问题,兄弟