Hey Guys,
I am a newbie in cakephp and wanted some guidance in the model associations before I bake the application. I have identified three entities called Users, Assessors and Invoices but couldn't figure out the correct associations since their logic is a lill different. Here is a brief summary of the web app:
1. Users login to the system and can search for Assessors. Users can select an Assessor and can only select one Assessor. If they want to select another Assessor then they need to first remove their current Assessor. Once the user selects an Assessor, their selected Assessor can create an Invoice that the user can view. Users can have multiple Invoices created by their selected Assessor.
2. Assessor’s can login to the system and view list of users that have selected them. They can create Invoices for their users. So Assessor can create zero or many invoices for their users.
I have done some research on model associations and was thinking of using the one to one relationship where dependence is equal to "False" on Users and Assessors so:
User has one Assessor but that would make the belongsTo association as a natural complement to the hasOne, so Assessor belongsTo Users - this is not necessarily true since an Assessor many not have any users or a User may not have any Assessor. Can someone provide me with some light here, I am confused :-)
I think I am clear with the association of Invoices with Users and Assessors, which is
Users has many Invoices
Assessors has many Invoices
Invoices belong to Users
Invoices belong to Assessors
Correct me if I am wrong but I am not very clear on what association to use between Users and Assessors?
Thanks,
Ket