PHP Trait Spatie\MediaLibrary\SortableTrait

Datei anzeigen Open project: spatie/laravel-medialibrary

Public Methods

Method Description
getHighestOrderNumber ( ) : integer * Determine the order value for the new record.
scopeOrdered ( Builder $query ) : Builder * Let's be nice and provide an ordered scope.
setHighestOrderNumber ( ) Modify the order column value.
setNewOrder ( array $ids, integer $startOrder = 1 ) This function reorders the records: the record with the first id in the array will get order 1, the record with the second it will get order 2, .
shouldSortWhenCreating ( ) : boolean * Determine if the order column should be set when saving a new model instance.

Protected Methods

Method Description
determineOrderColumnName ( ) : string Determine the column name of the order column.

Method Details

determineOrderColumnName() protected method

Determine the column name of the order column.
protected determineOrderColumnName ( ) : string
return string

getHighestOrderNumber() public method

* Determine the order value for the new record.
public getHighestOrderNumber ( ) : integer
return integer

scopeOrdered() public method

* Let's be nice and provide an ordered scope.
public scopeOrdered ( Builder $query ) : Builder
$query Illuminate\Database\Eloquent\Builder
return Illuminate\Database\Eloquent\Builder

setHighestOrderNumber() public method

Modify the order column value.

setNewOrder() public static method

.. A starting order number can be optionally supplied (defaults to 1).
public static setNewOrder ( array $ids, integer $startOrder = 1 )
$ids array
$startOrder integer

shouldSortWhenCreating() public method

* Determine if the order column should be set when saving a new model instance.
public shouldSortWhenCreating ( ) : boolean
return boolean