Skip to content
Advertisement

laravel breeze Multi Auth – Admin Guard with two diffirent registration

I’m using laravel breeze as auth scaffolding package.I want to create Multiple Authentication using laravel guards for two different registration form for two User Types (Admin, User).

The Main Idea of what I want to achieve :

I have two tables in the database one for admins and another for users what I want to achieve is if the admins choose to register an account as admin it will display a register form with specified fields for admin. after that I want to check if the user is logged in as admin or user if is logged in as admin is will redirect him/her to specified dashboard made only for admins.

It works fine for registration, but can’t login as a admin here is a simple explanation of what I want to achieve:

appModelsAdmin.php

JavaScript

configauth.php

JavaScript

appHttpMiddlewareRedirectIfAuthenticated.php

JavaScript

routesweb.php

JavaScript

appHttpControllersAdminAuthenticatedSessionController.php

JavaScript

appHttpControllersAdminRegisteredUserController.php

JavaScript

appHttpRequestsAdminLoginRequest.php

JavaScript

Advertisement

Answer

After 3 days effort i found a solution myself.

In the function authenticate() in appHttpRequestsAdminLoginRequest.php. I have replaced Auth::attempt(...) by Auth::guard('admin')->attempt(...)

JavaScript

Now it works fine for admin login and register

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement