1

I have this Controller:

    class AdminLoginController extends Controller
    {
        public function index() {
            return view('auth.admin.login');
        }
    }

route\web

    Route::get('/admin/login', 'Auth\AdminLoginController@index')->name('admin.login');

I am using spatie

How do I do it that if the logged in user is not 'Super Admin'

> Auth::user()->hasRole('Super Admin')

The application should display Access Denied. But if its super admin, it should redirect to dashboard.

How can I get this done?

Thanks

apokryfos
  • 38,771
  • 9
  • 70
  • 114
mikefolu
  • 1,203
  • 6
  • 24
  • 57

1 Answers1

0
  1. Add new role in config/auth.php such as admin role.

  2. Redefine redirect url in login controller for that role. (You can set it with Access Denied page)

  3. Please add constructor in Dashboard controller as following

    public function __construct() { $this->middleware('auth:super_admin'); }

WebDev
  • 587
  • 1
  • 6
  • 23