hiall!

Tell me, plz, is there a possibility in the falcon to sort the records in the default model?

At the moment, he has created 2 models - tasks and comments to those, after which he linked them by task-> id.

I want the task-> comments to immediately return the array sorted by date DESC with a limit of 10. Thank you!

    1 answer 1

    I have defined the connection of tasks with comments:

    $this->hasMany('id', __NAMESPACE__ . '\TaskComments', 'task_id', array( 'alias' => 'comments' )); 

    As a result, in the task model I define a new function.

     public function getSortedComments() { return $this->getComments(array( 'order' => 'date DESC' )); } 

    And then I refer to the sorted comments as

     task->sortedcomments 

    Curve option?