In my CakePHP application I have a model called 'Customer' which describes (unsurprisingly) an individual customer. I then have a 'Sale' model about a sale. (One customer per sale, many sales per customer). Each sale then has a 'car_id' (which maps to the 'Car' model) and an 'engine_id' (maps to 'Engine model'). Currently when I get the details of one customer, it pulls in the details of each sale associated that that customer, but I want to go one 'step' deeper and have, for each sale, the details of each car and of each engine. How do I do this?
I understand the relationships between the models, but I'm clearly missing something. My current set up is like this...
Customer: $hasMany = 'Sales';
Sale: $hasOne = array('Car', 'Engine');
Obviously the 'Car' and 'Engine' don't have a sale_id associated because they can belong to lots of different sales.