Answer the question
In order to leave comments, you need to log in
User model with role attribute or separate models?
Good afternoon!
The user can be either a seller or a buyer.
Better:
User model with attribute role: "seller" || "buyer"
or
Individual models Seller, Buyer ?
Answer the question
In order to leave comments, you need to log in
If the task remains only on this, then you can generally make a boolean field of the seller type , and call the seller in the context of the program ? to check who is the buyer or seller .
But this is if you do not appear in the future, for example, even the role of a manager or consultant! Then this approach is not logical. Then it is better to refer to the answer of Alexey POS_troi , he showed a method where roles are stored in a separate model, and the user has a binding to this role.
When designing a database and (or) a model, you need to look forward a little.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question