Monday, December 22, 2014

Re: How to associate 3 models (or structure a search) to achieve the following structure (Cake 2.x)

Please describe your Customer and Contact with more words. What are they in relation to each other?

For example:
We register information on our customers. For each customer, we have registered the employees that we use as contact when we wish to contact the customer on specific subjects.

The customer has a main office in one location and several other offices in other locations. Thus we need also to know which of the contact people are located in the specific location/office.

When you try and describe the relation between customer and contacts and other objects that may be of interest, then it will be easier for us to help you :)

Enjoy, John


On Sunday, 21 December 2014 01:33:43 UTC+2, Chris wrote:
Hi all!

I'm quite new to Cake and this is my first project. 

I'm working on a customer database. For larger business customers the relationships get a little complicated. I have 3 models, Customer, CustomerAddress and CustomerContact. A customer can have many addresses, and many contacts, but the contacts are also based at one address so an address has many contacts.

The end result I'm trying to achieve is to be able to search the data both ways, e.g.

Customer -> Address 1 -> Contact 1
                         
Contact 2
                         
Contact 3
                         
....

           
Address 2 -> Contact 1
                         
....
           
....


Or....

Customer -> Contact 1 -> Address
           
Contact 2 -> Address
           
....

I currently have it working as the first example, but found this problematic when I wanted to search the contacts, I have to search all the addresses too. If I search the contact I want to be able to get the address for that contact too, as in the second example. 

I'm not sure how to set this up, bit of help would be much appreciated to get me on the right track.

TIA! 

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: