Home > Software design >  Multiple roles with different attributes Laravel
Multiple roles with different attributes Laravel

Time:10-07

I have 3 roles for users: Admin, Editor, Normal user, and made a seperate table for roles, but my problem is that the (normal user) role have much more attributes/entries than the editor or the admin.

Whats the best practice for it?

Should I stick to the Users table and add those attributes as nullable? since the admin/editor does not need to fill it.

or make a new user_details table with one to one relation with the user?

CodePudding user response:

I would recommend going with a user_details table in this case.

CodePudding user response:

I often put non required fields for the other users nullable in users table migration file, And force them to be filled with code or logic (Request file). You can use in request validation required_if:role,normal

  • Related