[Solar-talk] How can i implement ordering on a
_belongsToor_hasMany relationship
Antti Holvikari
anttih at gmail.com
Wed Feb 20 09:04:17 CST 2008
On Wed, Feb 20, 2008 at 4:21 PM, Raymond Kolbe <rkolbe at gmail.com> wrote:
> I suppose you could write up your own method in that model. Have it get the
> related data/model, etc and pass $params to your method to do sorting.
>
> Other than that, I do not believe there are any built in ways to do what you
> want (Paul's suggestion was the closest).
You could implement __getYourRelatedModelHere() method in your record
and act based on a variable defined in the record. Like:
$record->order_employees = 'something'; // or whatever is you
related model's name
// This would call your magic getter and
// fetch data according to a record property we just set
$related = $record->employees;
I think there's even one more option. Manipulate your related object
and set it's ordering.
$employees = $model->getRelated('employees');
$employees->order = 'something';
// from now on all employees are ordered by 'something'
// when you access them from $model
--
Antti Holvikari <http://anttih.com>
More information about the Solar-talk
mailing list