私はlaravel 5.4を使用して、私は別のページlaravelは - 別のページ
スキーマへのユーザーのこれらの3つの異なる種類をリダイレクトするには、複数の認証をリダイレクトするために失敗した
Types
+-------+-------------+
| id | name |
+-------+-------------+
| 1 | Super Admin |
| 2 | Admin |
| 3 | Cashier |
+-------+-------------+
Users
+-------+---------+-------------+
| id | type_id | name |
+-------+---------+-------------+
| 1 | 1 | Super Admin |
| 2 | 2 | Admin |
| 3 | 3 | Cashier |
+-------+---------+-------------+
LoginController
public function redirectTo()
{
if (Auth::user()->type_id === 1) {
return '/superAdmin/home';
}
elseif (Auth::user()->type_id === 2) {
return '/admin/home';
}
elseif (Auth::user()->type_id === 3) {
return '/kasir/home';
}
}
HomeControllerの
public function superAdmin()
{
return view('superAdmin.home');
}
public function admin()
{
return view('admin.home');
}
public function kasir()
{
return view('kasir.home');
}
ルート
Route::get('/', '[email protected]');
Route::get('/admin/home', '[email protected]');
Route::get('/superAdmin/home', '[email protected]');
は私が意味するTYPE_ID = 1でユーザーを使用してサインインしようとした
redirecting three different user types/roles to different pages
私の前の質問の答えを踏襲しましたユーザーはスーパー管理者ですが、常にRoute::get('/','[email protected]');
にリダイレクトされます他の役割を持つユーザーとして
と問題は、それぞれの役割は、別の役割に属しているページにアクセスできることです、私はそれを修正するために何をすべきですか?
あなたのログインコントローラで '==='の代わりに '==='を試してください – HirenMangukiya
@HirenMangukiya私はそれを試しましたが、これは以前と同じです –
あなたは 'Auth :: user ) - > type_id' – HirenMangukiya