Support the ongoing development of Laravel.io →
Authentication Input Eloquent
Last updated 1 year ago.
0

you are doing it wrong! your db structure should be:

users(id, username, password, member_type) where member_type can change to be admin or user..

0

shez1983 said:

you are doing it wrong! your db structure should be:

users(id, username, password, member_type) where member_type can change to be admin or user..

yes, I understand :)

but if using 2 different tables for auth, is it possible?

Last updated 9 years ago.
0

It's possible, but it wouldn't be "easy" for a "newbie". There are also some concerns and some questions that come to mind, such as what happens when you have the same username in both tables? the same username and same password? are you going to use two different login forms?

At best, I imagine using one table per "role", within Laravel, means much more work for no extra benefit.

If possible, you should strongly consider using shez1983's suggestion. As it's likely the easiest way.

There's another method, which I prefer, where you have three tables. users, roles, and user_role. The 3rd is a pivot table used to relate users and roles. Users belongToMany Roles and Roles belongToMany Users. However, this might be overkill for your assignment.

Last updated 9 years ago.

manojibcarockers liked this reply

1

textbookcharlie said:

It's possible, but it wouldn't be "easy" for a "newbie". There are also some concerns and some questions that come to mind, such as what happens when you have the same username in both tables? the same username and same password? are you going to use two different login forms?

At best, I imagine using one table per "role", within Laravel, means much more work for no extra benefit.

If possible, you should strongly consider using shez1983's suggestion. As it's likely the easiest way.

There's another method, which I prefer, where you have three tables. users, roles, and user_role. The 3rd is a pivot table used to relate users and roles. Users belongToMany Roles and Roles belongToMany Users. However, this might be overkill for your assignment.

thank you for the explanation.

I think this is not will be easy, especially because I'm a newbie in laravel..

but thank you for the solution :)

0

Same problem.

When admin login and member login use same code

Auth::user();

I has been set auth in fillters.php

Last updated 9 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

yocha19 yocha19 Joined 16 Jan 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.