Implement specialization in Eloquent
Hello.
I'm currently building a web-store app and I want to implement 3 different roles for registered users: admin, salesman and customer.
Admin and salesman share the same attributes, so I decided to put them into 'users' table, whereas customer has some additional unique attributes (e.g. phone number and home address) and thus has his own 'customers' table, which is only populated with those attributes. Of course, I'm planning to implement polymorphic relations in 'users' table, so that each role has it's own model, without the need to create dedicated tables.
I saw many of you suggested implementing STI (single-table inheritance) on similar occasions, but I don't want to have null attributes in my 'users' table. It's really not that "dry" and I'm sure there's a better way to implement that.
So my question is: how can I implement MySQL specialization in Eloquent? I want to call Customer::find($id) and get all attributes from 'customers' table PLUS shared attributes in 'users' table (and similar, when calling Admin::find($id) I want to fetch only attributes in 'users' table).
P.S.: I hope you understood my question. If not, I'll try to post more broken english in this thread.
Please or to participate in this conversation.