Sortable
Sortable model behavior
class Winter\Storm\Database\Behaviors\Sortable
extends Winter\Storm\Extension\ExtensionBase
Usage:
Model table must have sort_order table column.
In the model class definition:
public $implement = [ \Winter\Storm\Database\Behaviors\Sortable::class, ];
To set orders:
$model->setSortableOrder($recordIds, $recordOrders);
You can change the sort field used by declaring this in your model:
const SORT_ORDER = 'my_sort_order';
Traits
Trait | Description |
---|---|
ExtensionTrait
|
Extension trait |
Properties
protected $model : mixed
public
static
$extendableStaticCalledClass
:
string
= null
Inherited from
ExtensionTrait
The calling class when using a static method.
protected
static
$extensionCallbacks
:
array
= []
Inherited from
ExtensionTrait
Used to extend the constructor of an extension class. Eg:
BehaviorClass::extend(function($obj) { })
protected
$extensionHidden
:
mixed
= {"fields":[],"methods":["extensionIsHiddenField","extensionIsHiddenMethod"]}
Inherited from
ExtensionTrait
Methods
public __construct ($parent)
Parameters
Property | Type | Description |
---|---|---|
$parent | mixed |
mixed
|
Returns
mixed
public bootSortable () : void
Boot the sortable behavior for this model.
Returns
void
public getSortOrderColumn () : string
Get the name of the "sort order" column.
Returns
string
public
setSortableOrder (mixed $itemIds, array $itemOrders = null
)
: void
Sets the sort order of records to the specified orders. If the orders is undefined, the record identifier is used.
Parameters
Property | Type | Description |
---|---|---|
$itemIds | mixed |
mixed
|
$itemOrders | array |
array
|
Returns
void
public static extend (callable $callback)
Inherited from
ExtensionBase
Parameters
Property | Type | Description |
---|---|---|
$callback | callable |
callable
|
Returns
mixed
public extensionApplyInitCallbacks ()
Inherited from
ExtensionTrait
Returns
mixed
public static extensionExtendCallback (callable $callback) : void
Inherited from
ExtensionTrait
Helper method for ::extend()
static method
Parameters
Property | Type | Description |
---|---|---|
$callback | callable |
callable
|
Returns
void
public extensionIsHiddenField ($name)
Inherited from
ExtensionTrait
Parameters
Property | Type | Description |
---|---|---|
$name | mixed |
mixed
|
Returns
mixed
public extensionIsHiddenMethod ($name)
Inherited from
ExtensionTrait
Parameters
Property | Type | Description |
---|---|---|
$name | mixed |
mixed
|
Returns
mixed
public static getCalledExtensionClass ()
Inherited from
ExtensionTrait
Returns
mixed
protected extensionHideField ($name)
Inherited from
ExtensionTrait
Parameters
Property | Type | Description |
---|---|---|
$name | mixed |
mixed
|
Returns
mixed
protected extensionHideMethod ($name)
Inherited from
ExtensionTrait
Parameters
Property | Type | Description |
---|---|---|
$name | mixed |
mixed
|
Returns
mixed
Copyright © 2023 Winter CMS