Nos\
Orm_Behaviour_Sortable
¶Makes a Nos\Orm\Model
sortable.
Nos\Orm_Behaviour_Sortable::$
sort_property
¶Required.
Column name use for save sort index. Column must have type double
.
Nos\Orm_Behaviour_Sortable::$
sort_order
¶ASC
(default) ou DESC
Nos\Orm_Behaviour_Sortable::$
sort_twins
¶True
by default. If false
and the model is twinnable, the sorting won’t be common to all contexts.
Nos\Orm_Behaviour_Sortable::
move_before
($item)¶Parameters: |
|
---|
Nos\Orm_Behaviour_Sortable::
move_after
($item)¶Parameters: |
|
---|
Nos\Orm_Behaviour_Sortable::
move_to_last_position
()¶Moves the current item to the last position (of its siblings).
<?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);