I can suggest a solution for you is you can use multiple if condition and limited the permissions.refer below one.
https://laracasts.com/discuss/channels/laravel/display-data-based-on-user-role
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Guys i am working with a project, inventory manage system like project.
the project is for a hotel to maintain their purchase product details, daily income, daily expenses, employee management, employee salary, their advance their betta, etc etc.
the hotel is maintaining three branches. so what i decided to make three logins to differentiate their accounts for three hotels S1,S1,S3.
Everything worked fine.
with few corrections i have uploaded the project in the server. and they started entering the information.
Now i am facing a new problem.
this is my users table columns
id,
hotel_name,
hotel_location
type,
phno,
password,
remember_token
Here the hotel_name is my user name.
these are the records in it.
id, hotel_name hotel_location type phno password
1 S1 bus stand user 123 @$#%JJ
2 S2 old bus stand user 321 KI**())(
Now i enter the data inincome table is
id login_user_id income_date income_type_id income_amount
1 1 6-04-19 1 200
2 1 6-04-19 2 100
3 1 6-04-19 3 50
4 2 6-04-19 4 600
5 2 6-04-19 5 700
6 2 6-04-19 6 800
here whats my problem is i have differentiated the data inside the tables based on the user id. if it is S1 that is id =1 means then it belongs to hotel 1 data and so on.
now what my client expecting is he needs two user for a single hotel with different permissions.
this is my store method for all the purchase,sales,income, expenses. For all the tables i have a column login_user_id. and whenever the data is inserted i usedauth()->id() to store the data belongs to which hotel
$stock->login_user_id=auth()->id();
whether this is right?? is this a right way to differentiate the hotel with their user id? or i need to use any other column to differentiate it?
and this is my index for all the purchase, expenses, income
$products = Product::where ('login_user_id',auth()->id())->orderBy('created_at','asc')->paginate(10);
i used where ('login_user_id',auth()->id()) line in all the index method to show the records for that pariticular login hotel.
the same doubt whether it is right or wrong? else what?
now my problem is is there any need to change the whole db?? i am so confused.. what to do??
what my client asking is there are two persons to enter the date in the hotel 1
person 1 can only enter the data, he dont have any permission to edit or delete the records. and
person 2 can add, edit or delete the data.
simply to say. for hotel 1 itself there are three users
super admin - manager
admin - accountant
user -- employee
three of them must access the same hotel only. but their permissions are different.
what i thought is to create a new user like S4 with the user_type as employee
so the employee from the same hotel hotel can add a record but we can restrict the permission.
but the login_user_id for the table will change. so the calculation will get affected. i will face many problems.
what can i do??
that is more than one person will enter the data for a single hotel itself. the data must be differentiated with their respective hotels and also need to restricted with permissions for those users who use the system.
in one hotel itself more than one person will enter the data. for that particular hotel data only.
Kindly some one please suggest you idea. kindly make me it to simple. because if i need to reconstruct the table means it takes time and the live data will be lost.
so kindly help me to solve this problem
I can't architect the whole program because I don't know if this is for a single organisation or multiple.
Is it a multi-tenant system?
So, which comes first, chicken or egg?
User registers on your site. As they only just registered, are they to be associated with an existing hotel or create a new hotel. Likely they create a new hotel. Now the hotel has an 'owner'
The owner of the hotel might want to register other users for that hotel so there needs to be a table of hotel_users which tells you which users are associated with the hotel.
If a user can be associated with a second hotel then they can be added as an extra row in this table.
Now this user has two hotels to choose from. When they login they can see a page that asks which hotel they want to work with. They could have a navbar entry to switch hotels.
You store their current hotel choice in their session. For users that don't have multiple hotels, just put their one hotel in the session. Now all users have a hotel in session.
You can now create Global scopes that apply to all models and only show records that are for the hotel that the user is working with.
may i know for why i need to store the user in all table
If you have 2,3,4 users at one hotel, which user created the purchase order? Which user booked expenses or recorded income?
Please or to participate in this conversation.