mardi 9 octobre 2018

Laravel, seemingly complex eloquent relationships

I am really having some issues getting my head around this, but, I'll try to explain what it is that I want to achieve and hopefully one of you can point me in the right direction.

I have a Role entity, nothing crazy here just a name field.

I also have a RoleField entity, this is used to basically build forms and will contain information like, field_type.

A user can assign themselves a Role so I have a table user_roles, but a user can also have answers to the form that was built using the RoleField entity. This is the bit that is giving me headaches.

Some of this might be a matter of opinion and I know that this place isn't meant for opinions but there is also some hard answers in there somewhere.

So firstly, what is the optimal database structure for a scenario that a user has the ability to save answers to their role. What would these relationships look like? Should I structure my endpoints to be user/1/role/1/field/1/answer seems rather long winded?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire