PHP Трейт Lookitsatravis\Listify\Listify

http://lookitsatravis.github.io/listify Ported from https://github.com/swanandp/acts_as_list
Автор: Travis Vignon ([email protected])
Показать файл Открыть проект

Открытые методы

Метод Описание
addNewAt ( ) : string Returns the value of the 'add_new_at' option
bootListify ( ) : boolean Returns whether the scope has changed during the course of interaction with the model
decrementPosition ( ) : void Decrease the position of this item without adjusting the rest of the list.
defaultPosition ( ) : mixed Get the default item position
getListifyPosition ( ) : integer Returns the value of the model's current position
higherItem ( ) : mixed Return the next higher item in the list.
higherItems ( integer $limit = NULL ) : mixed Return the next n higher items in the list. Selects all higher items by default
incrementPosition ( ) : void Increase the position of this item without adjusting the rest of the list.
initListify ( array $options = [] ) : void Required to override options and kick off the Listify's automatic list management.
insertAt ( integer $position = NULL ) : void Insert the item at the given position (defaults to the top position of 1).
isDefaultPosition ( ) : boolean Returns whether the item's current position matches the default position
isFirst ( ) : boolean Returns if this object is the first in the list.
isInList ( ) : boolean Returns whether the item is in the list
isLast ( ) : boolean Returns if this object is the last in the list.
isNotInList ( ) : boolean Returns whether the item is not in the list
listifyTop ( ) : string Get the value of the "top_of_list" option
lowerItem ( ) : mixed Return the next lower item in the list.
lowerItems ( integer $limit = NULL ) : mixed Return the next n lower items in the list. Selects all lower items by default.
moveHigher ( ) : void Swap positions with the next higher item, if one exists.
moveLower ( ) : void Swap positions with the next lower item, if one exists.
moveToBottom ( ) : void Move to the bottom of the list. If the item is already in the list, the items below it have their positions adjusted accordingly.
moveToTop ( ) : void Move to the top of the list. If the item is already in the list, the items above it have their positions adjusted accordingly.
positionColumn ( ) : string Get the name of the position 'column' option
removeFromList ( ) : void Removes the item from the list.
scopeInList ( $query ) : Eloquent An Eloquent scope that returns only items currently in the list
scopeListifyScope ( $query ) : Eloquent An Eloquent scope based on the processed scope option
scopeName ( ) : mixed Get the value of the 'scope' option
setListPosition ( integer $new_position ) : void Sets the new position and saves it
setListifyConfig ( $key, $value ) : void Updates a listify config value
setListifyPosition ( integer $position ) : void Sets the value of the model's position
swapChangedAttributes ( ) : void Temporarily swap changes attributes with current attributes

Приватные методы

Метод Описание
addToListBottom ( ) : void Adds item to the bottom of the list
addToListTop ( ) : void Adds item to the top of the list
assumeBottomPosition ( ) : void Forces item to assume the bottom position in the list.
assumeTopPosition ( ) : void Forces item to assume the top position in the list.
bottomItem ( mixed $except = NULL ) : mixed Returns the bottom item
bottomPositionInList ( mixed $except = NULL ) : integer Returns the bottom position number in the list
checkScope ( ) : void Determines whether scope has changed. If so, it will move the current item to the top/bottom of the list and update all other items
decrementPositionsOnLowerItems ( integer $position = NULL ) : void This has the effect of moving all the lower items up one.
getConditionStringFromQueryBuilder ( $query ) : string Returns a raw WHERE clause based off of a Query Builder object
hasScopeChanged ( ) : boolean Returns whether the scope has changed during the course of interaction with the model
incrementPositionsOnAllItems ( ) : void Increments position of all items in the list.
incrementPositionsOnHigherItems ( ) : void This has the effect of moving all the higher items down one.
incrementPositionsOnLowerItems ( integer $position ) : void This has the effect of moving all the lower items down one.
insertAtPosition ( integer $position ) : void Inserts the item at a particular location in the list. All items around it will be modified
listifyList ( ) : mixed Creates an instance of the current class scope as a list
primaryKey ( ) : string Returns the primary key of the current Eloquent instance
reloadPosition ( ) : void Reloads the position value of the current item. This is only called when an item is deleted and is here to prevent unsetting the position column which would prevent other items from being moved properly
scopeCondition ( ) : string Returns the raw WHERE clause to be used as the Listify scope
shufflePositionsOnIntermediateItems ( integer $old_position, integer $new_position, string $avoid_id = NULL ) : void Reorders intermediate items to support moving an item from old_position to new_position.
updatePositions ( ) : void Updates all items based on the original position of the item and the new position of the item

Описание методов

addNewAt() публичный Метод

Returns the value of the 'add_new_at' option
public addNewAt ( ) : string
Результат string

bootListify() публичный статический Метод

Returns whether the scope has changed during the course of interaction with the model
public static bootListify ( ) : boolean
Результат boolean

decrementPosition() публичный Метод

Decrease the position of this item without adjusting the rest of the list.
public decrementPosition ( ) : void
Результат void

defaultPosition() публичный Метод

Get the default item position
public defaultPosition ( ) : mixed
Результат mixed

getListifyPosition() публичный Метод

Returns the value of the model's current position
public getListifyPosition ( ) : integer
Результат integer

higherItem() публичный Метод

Return the next higher item in the list.
public higherItem ( ) : mixed
Результат mixed Returned item will be of the same type as the current class instance

higherItems() публичный Метод

Return the next n higher items in the list. Selects all higher items by default
public higherItems ( integer $limit = NULL ) : mixed
$limit integer The number of items to return
Результат mixed Returned items will be of the same type as the current class instance

incrementPosition() публичный Метод

Increase the position of this item without adjusting the rest of the list.
public incrementPosition ( ) : void
Результат void

initListify() публичный Метод

Required to override options and kick off the Listify's automatic list management.
public initListify ( array $options = [] ) : void
$options array [column=>string, scope=>string|BelongsTo|Builder, top_of_list=>int, add_new_at=>string]
Результат void

insertAt() публичный Метод

Insert the item at the given position (defaults to the top position of 1).
public insertAt ( integer $position = NULL ) : void
$position integer
Результат void

isDefaultPosition() публичный Метод

Returns whether the item's current position matches the default position
public isDefaultPosition ( ) : boolean
Результат boolean

isFirst() публичный Метод

Returns if this object is the first in the list.
public isFirst ( ) : boolean
Результат boolean

isInList() публичный Метод

Returns whether the item is in the list
public isInList ( ) : boolean
Результат boolean

isLast() публичный Метод

Returns if this object is the last in the list.
public isLast ( ) : boolean
Результат boolean

isNotInList() публичный Метод

Returns whether the item is not in the list
public isNotInList ( ) : boolean
Результат boolean

listifyTop() публичный Метод

Get the value of the "top_of_list" option
public listifyTop ( ) : string
Результат string

lowerItem() публичный Метод

Return the next lower item in the list.
public lowerItem ( ) : mixed
Результат mixed Returned item will be of the same type as the current class instance

lowerItems() публичный Метод

Return the next n lower items in the list. Selects all lower items by default.
public lowerItems ( integer $limit = NULL ) : mixed
$limit integer The number of items to return
Результат mixed Returned items will be of the same type as the current class instance

moveHigher() публичный Метод

Swap positions with the next higher item, if one exists.
public moveHigher ( ) : void
Результат void

moveLower() публичный Метод

Swap positions with the next lower item, if one exists.
public moveLower ( ) : void
Результат void

moveToBottom() публичный Метод

Move to the bottom of the list. If the item is already in the list, the items below it have their positions adjusted accordingly.
public moveToBottom ( ) : void
Результат void

moveToTop() публичный Метод

Move to the top of the list. If the item is already in the list, the items above it have their positions adjusted accordingly.
public moveToTop ( ) : void
Результат void

positionColumn() публичный Метод

Get the name of the position 'column' option
public positionColumn ( ) : string
Результат string

removeFromList() публичный Метод

Removes the item from the list.
public removeFromList ( ) : void
Результат void

scopeInList() публичный Метод

An Eloquent scope that returns only items currently in the list
public scopeInList ( $query ) : Eloquent
$query
Результат Eloquent Query Builder instance

scopeListifyScope() публичный Метод

An Eloquent scope based on the processed scope option
public scopeListifyScope ( $query ) : Eloquent
$query An Eloquent Query Builder instance
Результат Eloquent Query Builder instance

scopeName() публичный Метод

Get the value of the 'scope' option
public scopeName ( ) : mixed
Результат mixed Can be a string, an Eloquent BelongsTo, or an Eloquent Builder

setListPosition() публичный Метод

Sets the new position and saves it
public setListPosition ( integer $new_position ) : void
$new_position integer
Результат void

setListifyConfig() публичный Метод

Updates a listify config value
public setListifyConfig ( $key, $value ) : void
Результат void

setListifyPosition() публичный Метод

Sets the value of the model's position
public setListifyPosition ( integer $position ) : void
$position integer
Результат void

swapChangedAttributes() публичный Метод

Temporarily swap changes attributes with current attributes
public swapChangedAttributes ( ) : void
Результат void