1

I'm developing a yii2 rest api based app that has different roles of users (Admin, Customer, Shop, Service). I'm planning to use scenarios with one user database table contains union of fields that requires all roles. (80% is the same) I would like to define different validation types, different visible fildes and different related records based on scenario(user role). As i see it is possible.

My question is: Is it a good solution or scenarios tend to be only for handling validation differences for the same object (ex.: update, create, regsiter, etc...) and i should make multiple user tables not roles?

Thanks

Bence
  • 63
  • 4
  • 1
    you can avoid cramming all the scenarios and custom logic in a single model by having multiple AR classes for each user role (`Customer extends base\User`) you'll be able to override any basic functionality of User without having to separate tables. take it as just an idea, without in-depth requirements i can't tell if it's the best solution for you – csminb May 17 '18 at 12:56
  • @csminb thanks for your comment. Not a bad idea. My webuser identity class would be the base user class and when user manipulate data example in a profile menu i should use the extended AR classes. Maybe a function in webuser that returns the the current extended AR class based on role would be useful. I will play with that idea. Thanks again. – Bence May 18 '18 at 18:15

0 Answers0