PHP Trait Lookitsatravis\Listify\Listify

http://lookitsatravis.github.io/listify Ported from https://github.com/swanandp/acts_as_list
Author: Travis Vignon ([email protected])
Afficher le fichier Open project: lookitsatravis/listify

Méthodes publiques

Méthode Description
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

Private Methods

Méthode Description
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

Method Details

addNewAt() public méthode

Returns the value of the 'add_new_at' option
public addNewAt ( ) : string
Résultat string

bootListify() public static méthode

Returns whether the scope has changed during the course of interaction with the model
public static bootListify ( ) : boolean
Résultat boolean

decrementPosition() public méthode

Decrease the position of this item without adjusting the rest of the list.
public decrementPosition ( ) : void
Résultat void

defaultPosition() public méthode

Get the default item position
public defaultPosition ( ) : mixed
Résultat mixed

getListifyPosition() public méthode

Returns the value of the model's current position
public getListifyPosition ( ) : integer
Résultat integer

higherItem() public méthode

Return the next higher item in the list.
public higherItem ( ) : mixed
Résultat mixed Returned item will be of the same type as the current class instance

higherItems() public méthode

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
Résultat mixed Returned items will be of the same type as the current class instance

incrementPosition() public méthode

Increase the position of this item without adjusting the rest of the list.
public incrementPosition ( ) : void
Résultat void

initListify() public méthode

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]
Résultat void

insertAt() public méthode

Insert the item at the given position (defaults to the top position of 1).
public insertAt ( integer $position = NULL ) : void
$position integer
Résultat void

isDefaultPosition() public méthode

Returns whether the item's current position matches the default position
public isDefaultPosition ( ) : boolean
Résultat boolean

isFirst() public méthode

Returns if this object is the first in the list.
public isFirst ( ) : boolean
Résultat boolean

isInList() public méthode

Returns whether the item is in the list
public isInList ( ) : boolean
Résultat boolean

isLast() public méthode

Returns if this object is the last in the list.
public isLast ( ) : boolean
Résultat boolean

isNotInList() public méthode

Returns whether the item is not in the list
public isNotInList ( ) : boolean
Résultat boolean

listifyTop() public méthode

Get the value of the "top_of_list" option
public listifyTop ( ) : string
Résultat string

lowerItem() public méthode

Return the next lower item in the list.
public lowerItem ( ) : mixed
Résultat mixed Returned item will be of the same type as the current class instance

lowerItems() public méthode

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
Résultat mixed Returned items will be of the same type as the current class instance

moveHigher() public méthode

Swap positions with the next higher item, if one exists.
public moveHigher ( ) : void
Résultat void

moveLower() public méthode

Swap positions with the next lower item, if one exists.
public moveLower ( ) : void
Résultat void

moveToBottom() public méthode

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
Résultat void

moveToTop() public méthode

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
Résultat void

positionColumn() public méthode

Get the name of the position 'column' option
public positionColumn ( ) : string
Résultat string

removeFromList() public méthode

Removes the item from the list.
public removeFromList ( ) : void
Résultat void

scopeInList() public méthode

An Eloquent scope that returns only items currently in the list
public scopeInList ( $query ) : Eloquent
$query
Résultat Eloquent Query Builder instance

scopeListifyScope() public méthode

An Eloquent scope based on the processed scope option
public scopeListifyScope ( $query ) : Eloquent
$query An Eloquent Query Builder instance
Résultat Eloquent Query Builder instance

scopeName() public méthode

Get the value of the 'scope' option
public scopeName ( ) : mixed
Résultat mixed Can be a string, an Eloquent BelongsTo, or an Eloquent Builder

setListPosition() public méthode

Sets the new position and saves it
public setListPosition ( integer $new_position ) : void
$new_position integer
Résultat void

setListifyConfig() public méthode

Updates a listify config value
public setListifyConfig ( $key, $value ) : void
Résultat void

setListifyPosition() public méthode

Sets the value of the model's position
public setListifyPosition ( integer $position ) : void
$position integer
Résultat void

swapChangedAttributes() public méthode

Temporarily swap changes attributes with current attributes
public swapChangedAttributes ( ) : void
Résultat void