Hi Sonic,

Glad I could help - see my comments below.

Geoff

On 8/9/07, Sonic Baker <[EMAIL PROTECTED]> wrote:
>
> Hey Geoff,
>
> Thanks for second the reply dude, and thanks even more for your level of
> detail with your thoughts. The profile stuff is clear to me now and I'll be
> adapting my current Models to use an abstract factory on asap. The only
> thing I'm having trouble with now is how to know which account a user
> belongs to when they log in. (please see below)
>
>
> On 8/8/07, Geoff Ford <[EMAIL PROTECTED]> wrote:
> >
> >
> > Customer hasMany Accounts - a customer is a User with a
> > CustomerProfile
>
>
> Yep, that's what I have.
>
> Account belongsTo AccountAdmin(admin), AccountManager(manager_id),
> > BillingContact(billing_contact_id)  (which are users)
>
>
>
> Aha, we're on the same page here too.
>
> I would keep the accounts table the way you have it now as I think the
> > above associations is more correct than User belongsTo Account.
>
>
> Ok, see this is where the trouble comes in. If I just leave the
> 'billing_contact_id' and 'account_manager_id' in the `accounts` table and
> don't have an 'account_id' in the User's `external_profiles` table, then how
> will I know what Account a BillingContact is trying to access when they log
> in?
> I'll have to search through the Account's for one who's
> 'billing_contact_id' is the same as the 'user_id' who logs on. That seems
> like a bit of a waste when an association could take care of it. Have I
> picked you up wrongly on this point?
>

Here is where Cake is really flexible - you can create the association in
Profile like ExternalProfile hasOne Account and then specify the foreign key
as billing_contact_id.  If you are using the same profile model for all
three account user types you will have to look into Model::bind() and
Model::unbind() to create this association as needed, and adapt the foreign
key to the user type.


Man I love complex data models and associations.  There are so many
> > different ways you can model them and everyone has a different idea as
> > to waht is correct.
>
>
> I love it too. Unfortunately, I don't have many people who are also into
> it and who I can run my thoughts by. It can get a bit messy inside one head
> :)
>

I know what you mean :) It can get lonely in your own head sometimes -
especially when you can't quite get it the way you want it :)

Feel free to say that eveything I just wrote is
> > crap and wont work in your situation. :)
>
>
> I think most of it'll be perfect. I just hope I haven't thrown a spanner
> in the works on the logging in thing. What do you think?
>
> Cheers,
>
> Sonic
>
>
> >
>


-- 
http://lemoncake.wordpress.com

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to