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';

Extends

Class Description
ExtensionBase

Extension class Allows for "Private traits"

Traits

Trait Description
ExtensionTrait

Extension trait

Properties

protected $model : mixed

inherited public static $extendableStaticCalledClass : string

Inherited from ExtensionTrait

The calling class when using a static method.

inherited protected static $extensionCallbacks : array

Inherited from ExtensionTrait

Used to extend the constructor of an extension class. Eg:

BehaviorClass::extend(function($obj) { })

inherited 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

inherited public static extend (callable $callback)

Inherited from ExtensionBase
Parameters
Property Description
$callback
callable
Returns
mixed

inherited public extensionApplyInitCallbacks ()

Inherited from ExtensionTrait
Returns
mixed

inherited public static extensionExtendCallback (callable $callback) : void

Inherited from ExtensionTrait

Helper method for ::extend() static method

Parameters
Property Description
$callback
callable
Returns
void

inherited public extensionIsHiddenField ($name)

Inherited from ExtensionTrait
Parameters
Property Description
$name
mixed
Returns
mixed

inherited public extensionIsHiddenMethod ($name)

Inherited from ExtensionTrait
Parameters
Property Description
$name
mixed
Returns
mixed

inherited public static getCalledExtensionClass ()

Inherited from ExtensionTrait
Returns
mixed

inherited protected extensionHideField ($name)

Inherited from ExtensionTrait
Parameters
Property Description
$name
mixed
Returns
mixed

inherited protected extensionHideMethod ($name)

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