Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jinsonjose's avatar

what is the best practice for building seperate login for user and admin in laravel 5.7 +

i am new in laravel i want to develop a blog site in laravel it need admin login and user login so how can i create different login in laravel 5.7+ (use single table or multiple table )

can you help me??

i already try different solutions but all the cases are fail laravel default authentication used for normal-users so how to add authentication for admin users

0 likes
11 replies
martinbean's avatar

@jinsonjose A login form is a login form.

You should have a single user model, and then use authorization to determine what a user can and cannot do in your application.

3 likes
jinsonjose's avatar

@MARTINBEAN - sir thanks for your comment can you provide an example of how to handle i think that will be a big help

my problem is how to create a user login and admin login (seperate logins) can you help me sir

shawnyv's avatar

In the simplest cases, just add an "is_admin" boolean to your user table.

If you expect to have more roles / a lot of different permissions associated with the admin role, then you may want to look into a package like Spatie's Permissions (https://github.com/spatie/laravel-permission)

jinsonjose's avatar

@SHAWNYV - sir , actually i want to create to login forms like url may be domainname/login and domainname/admin/login also if normal user can login through this url : domainname/login & admin users can login through this url :domainname/admin/login if an normal user login success then returned to home page and if an admin user login he will returned to dashboard page also logout normal user retrun to this url :domainname/login and admin user return to this url :domainname/admin/login i already add "is_admin" in users table and normal user can successfully login using laravel default auth command but the struggle part is how can we create the seprate admin login form and how to handle this last one week i will try so many solutions but my faith all fail can you help me

in my concern i have only two roles normal user and admin

can you provide an example it will help a lot again thanks for your support

steve_laracasts's avatar

I don't understand why the need for two login pages, this is completely redundant and is just making a lot of work for yourself, you'll have a much easier time following the advice that @martinbean gave

Then for the redirection you can just do something like if user is admin return admin view, else return home page view.

If you want to provide different information on the two login screens or just aesthetics and you really want a separate login screen, then create your two separate pages, but still use the same route to log the user in, this will work fine.

The same technique of returning a different view based on is_admin will work for the logout too.

1 like
jlrdw's avatar

I am being totally honest here, that question has been discussed many many times here with good answers.

Google

Site:laracasts.com authentication and authorization

And other Search terms as you see fit.

In fact a while back I gave an in-depth answer to that very same question.

And

Basically a user is a user, you can have separate login forms (areas) designed differently, but have same user table:

https://laracasts.com/discuss/channels/laravel/i-want-to-create-two-types-user-panel-for-two-types-user

jlrdw's avatar

@KEL_ - Actually a larger enterprise will have it separated, i.e., A large hospital chain:

The patient portal and doctor portal are not the same.

But yes for smaller apps where you have just users and admins, then same table should be used.

My first above answer was to show how to use the same table, but you may want completely separate looks and "feels" for what the login part looks like.

The State of Texas is the same, what the public sees and the "view" they see to create a login verses what an employee sees are two completely different looks, etc.

Remember, some here may be writing a more advanced app than a mere "blog" or whatever, and may need more of an enterprise way of doing things.

steve_laracasts's avatar

Interesting, I do see the psychology behind it, that makes sense; but to me it just seems silly to have two different authentication systems for the same app - if they are two separate apps that have different functionality, then sure have two separate logins, but if both sets of users are using the same functionality with different features then I still don't get the advantage to creating two completely separate login routes.

p.s. not that it matters, but you should know that I don't just write simple apps, far from it, and I am not sure how you would know what I do? Have we met previously?

1 like

Please or to participate in this conversation.