vendredi 26 février 2016

Need advice on laravel modeling (pivot of pivot)

I have a company auditing system, which is a bit difficult to explain but i will try to keep it simple. Here are the main parts

1) Comapny

2) Audits (certifications)

3) Clauses (These are questions specific to a certification and they all need to be answered in order for the audit to complete. The user can then add comments, status, mark it as complete etc )

There are lots of audits that a company can be tested for. So a company can have multiple audits. Each audit have some clauses, that needs to be executed in order to complete the audit. A user can also add some data to these clauses, for eg progress of the clause, status, comments etc.

Right now i have these database tables

1) Companies

2) Audits

3) Clauses

4) Companies - Audits (Pivot table)

5) Clauses - Audit (Pivot table)

6) Companies - Audits - Clauses (pivot of pivot table)

Now the first 5 are preety standard, but i am not sure how to impliment the last one. Right now in companies-audits pivot table i have an auto increment field called companies_audits_id, And i then use this id inside Companies_Audits_Clauses table. In Companies_Audits_Clauses table i also have the fields like status, progress, comments etc.

I am not sure if this is a good idea. So i need your thoughts on it. Every help is appreciated.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1QMeLDP
via IFTTT

Aucun commentaire:

Enregistrer un commentaire