1. use virtualFields
2. modify results in afterFind() Callback
3. create Helper and its method
4. use Entity(plugin) and define price() method(or magic property)
I will perhaps choose 3 or 4 because assumed that the user for calculation is on the context of actions.
e.g. function price($item, $user = null) => $user = AuthComponent::user() when no user given.
2013/7/2 frocco <farocco@gmail.com>
Hello,I have 4 price fields in my model.price1price2price3price4I only want to return a field called price for any queries.price will be one of the 4 price fields based on a condition.if userlevel is 'A' return price1if userlevel is 'B' return price2How can I do this in cakephp?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 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/groups/opt_out.
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/groups/opt_out.
No comments:
Post a Comment