1 year ago

Guys need a big suggestion for login permission for different users laravel

Posted 1 year ago by AbdulBazith

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


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


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

Please sign in or create an account to participate in this conversation.