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

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

Inherited from ExtensionTrait

Methods

public __construct ($parent)

Parameters
Property Description
$parent
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 Description
$itemIds
mixed
$itemOrders
array
Returns
void

public static extend (callable $callback)

Inherited from ExtensionBase
Parameters
Property Description
$callback
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 Description
$callback
callable
Returns
void

public extensionIsHiddenField ($name)

Inherited from ExtensionTrait
Parameters
Property Description
$name
mixed
Returns
mixed

public extensionIsHiddenMethod ($name)

Inherited from ExtensionTrait
Parameters
Property Description
$name
mixed
Returns
mixed

public static getCalledExtensionClass ()

Inherited from ExtensionTrait
Returns
mixed

protected extensionHideField ($name)

Inherited from ExtensionTrait
Parameters
Property Description
$name
mixed
Returns
mixed

protected extensionHideMethod ($name)

Inherited from ExtensionTrait
Parameters
Property Description
$name
mixed
Returns
mixed
Copyright © 2024 Winter CMS