This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Route::group(['as'=>'user.','prefix' => 'user','namespace'=>'User','middleware'=>['auth','user']], function () { | |
Route::get('dashboard', 'DashboardController@index')->name('dashboard'); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
Route::group(['as'=>'admin.','prefix' => 'admin','namespace'=>'Admin','middleware'=>['auth','admin']], function () { | |
Route::get('dashboard', 'DashboardController@index')->name('dashboard'); | |
}); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
public function __construct() | |
{ | |
if(Auth::check() && Auth::user()->role_id == 1){ | |
$this->redirectTo = route('admin.dashboard'); | |
} elseif(Auth::check() && Auth::user()->role_id == 2){ | |
$this->redirectTo = route('user.dashboard'); | |
} | |
$this->middleware('guest')->except('logout'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
public function handle($request, Closure $next, $guard = null) | |
{ | |
if (Auth::guard($guard)->check() && Auth::user()->role_id == 1) { | |
return redirect()->route('admin.dashboard'); | |
} elseif(Auth::guard($guard)->check() && Auth::user()->role_id == 2){ | |
return redirect()->route('user.dashboard'); | |
} else { | |
return $next($request); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
public function handle($request, Closure $next) | |
{ | |
if(auth::check() && Auth::user()->role_id == 2){ | |
return $next($request); | |
} | |
else { | |
return redirect()->route('login'); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(auth::check() && Auth::user()->role_id == 1){ | |
return $next($request); | |
} | |
else { | |
return redirect()->route('login'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function run() | |
{ | |
$this->call(UsersTableSeeder::class); | |
$this->call(RolesTableSeeder::class); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DB_DATABASE = devopsschool | |
DB_USERNAME = root | |
DB_PASSWORD = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
DB::table('users')->insert([ | |
'role_id' => '1', | |
'name' => 'Admin', | |
'email' => 'admin@gmail.com', | |
'password' => bcrypt('pass@admin'), | |
]); | |
DB::table('users')->insert([ | |
'role_id' => '2', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
DB::table('roles')->insert([ | |
'role_name' => 'Admin', | |
'role_slug' => 'admin', | |
]); | |
DB::table('roles')->insert([ | |
'role_name' => 'User', | |
'role_slug' => 'user', | |
]); |