Sortable¶
- class Nos\Orm_Behaviour_Sortable¶
Makes a Nos\Orm\Model sortable.
Configuration¶
- property Nos\Orm_Behaviour_Sortable::$sort_property¶
Required. Column name use for save sort index. Column must have type double.
- property Nos\Orm_Behaviour_Sortable::$sort_order¶
ASC (default) ou DESC
Methods¶
- Nos\Orm_Behaviour_Sortable::move_before($item)¶
Parameters: - $item (Model) – Moves the current item before this one.
- Nos\Orm_Behaviour_Sortable::move_after($item)¶
Parameters: - $item (Model) – Moves the current item after this one.
- Nos\Orm_Behaviour_Sortable::move_to_last_position()¶
Moves the current item to the last position (of its siblings).
Example¶
<?php
class Model_Page extends \Nos\Orm\Model
{
protected static $_behaviours = array(
'Nos\Orm_Behaviour_Sortable' => array(
'events' => array('after_sort', 'before_insert'),
'sort_property' => 'page_sort',
),
);
}
$page_1 = Model_Page::find(1);
$page_2 = Model_Page::find(2);
$page_2->move_after($page_1);