Laravel-8 with the Spatie permission package. I have already assigned role and permissions to my users. My problem is how can I route my users after logging in to a path according to their role?
I have the following roles: Admin, Manager, Administrative, Teacher, Student. I want your route to be something like this:
Route::group(['prefix' => 'admin', 'middleware' => ['auth', 'verified', 'role:Admin']], function() {
// ...
});
Route::group(['prefix' => 'manager', 'middleware' => ['auth', 'verified', 'role:Manager']], function() {
// ...
});
Route::group(['prefix' => 'teacher', 'middleware' => ['auth', 'verified', 'role:Teacher']], function() {
// ...
});
Route::group(['prefix' => 'student', 'middleware' => ['auth', 'verified', 'role:Student']], function() {`
// ...
});
2
Answers
In HomeController add this in the index method:
hi
an example is ready for you