Oh, and I forgot to ask... Could EVENTS possibly help me out here?

On Friday, June 21, 2013 4:21:16 PM UTC+2, Vanja Dizdarević wrote:
>
> I am designing a cart system and cannot quite decide how to handle the 
> multiple-codependent model values. This is quite a conceptual question, I 
> hope I can explain it right.
>
> Many properties of a certain Order (and associated Models) record are 
> dynamic (and directly affect each other) and I am trying to make a robust 
> data workflow which would yield the most stable, yet flexible results.
>
> Consider this model schema (unimportant properties are omitted):
>
> - Order [weight, total_charge, tax_charge, shipping_charge, country_id ...]
> - OrderItem [order_id, quantity, unit_price, discount, tax_rate, subtotal, 
>  ...]
> - Payment [order_id, amount, ...]
>
> If you change any of these properties, all others are affected.
> eg. Order.country_id affects Order.shipping_charge and OrderItem.tax_rate
> eg. OrderItem.discount affects OrderItem.subtotal, Order.total_charge and 
> Order.tax_charge.
> I would also like to be able to make "faux" calculations, without stored 
> data, by supplying only a data array and have all the data rendered.
> etc.
>
> I am wondering WHERE and HOW should I properly approach these connections 
> in their respective models? beforeSave callback, afterFind? Both? Make a 
> behavior?
>
> Does anyone have experience with this kind of co-dependence in Cake? How 
> to make it as clean and robust as possible?
>
> Thanks!
>
>
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to