PHP Трейт Stevebauman\Inventory\Traits\InventoryStockTrait

Наследование: use trait CommonMethodsTrait
Показать файл Открыть проект

Открытые свойства

Свойство Тип Описание
$cost integer | float | string Stores the cost for updating a stock.
$reason string Stores the reason for updating / creating a stock.

Защищенные свойства (Protected)

Свойство Тип Описание
$beforeQuantity integer | float | string Stores the quantity before an update.

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

Метод Описание
add ( integer | float | string $quantity, string $reason = '', integer | float | string $cost ) Alias for put function.
bootInventoryStockTrait ( ) Overrides the models boot function to set the user ID automatically to every new record.
getLastMovement ( ) : boolean | Model Returns the last movement on the current stock record.
getMovement ( integer | string | Model $movement ) : mixed Returns a movement depending on the specified argument. If an object is supplied, it is checked if it is an instance of an eloquent model. If a numeric value is entered, it is retrieved by it's ID.
hasEnoughStock ( integer | float | string $quantity ) : boolean Returns true if there is enough stock for the specified quantity being taken.
item ( ) : BelongsTo The belongsTo item relationship.
location ( ) : Illuminate\Database\Eloquent\Relations\HasOne The hasOne location relationship.
moveTo ( Model $location ) : boolean Moves a stock to the specified location.
movements ( ) : Illuminate\Database\Eloquent\Relations\HasMany The hasMany movements relationship.
newTransaction ( string $name = '' ) : Model Creates and returns a new un-saved stock transaction instance with the current stock ID attached.
postCreate ( ) : void Generates a stock movement after a stock is created.
postUpdate ( ) : void Generates a stock movement after a stock is updated.
put ( integer | float | string $quantity, string $reason = '', integer | float | string $cost ) Processes a 'put' operation on the current stock.
remove ( integer | float | string $quantity, string $reason = '', integer | float | string $cost ) Removes the specified quantity from the current stock.
rollback ( mixed $movement = null, boolean $recursive = false ) Rolls back the last movement, or the movement specified. If recursive is set to true, it will rollback all movements leading up to the movement specified.
rollbackMovement ( mixed $movement, boolean $recursive = false ) Rolls back a specific movement.
take ( integer | float | string $quantity, string $reason = '', integer | float | string $cost ) Processes a 'take' operation on the current stock.
transactions ( ) : Illuminate\Database\Eloquent\Relations\HasMany The hasMany transactions relationship.
updateQuantity ( integer | float | string $quantity, string $reason = '', integer | float | string $cost ) Performs a quantity update. Automatically determining depending on the quantity entered if stock is being taken or added.

Защищенные методы

Метод Описание
allowDuplicateMovementsEnabled ( ) : boolean Returns true/false from the configuration file determining whether or not stock movements can have the same before and after quantities.
generateStockMovement ( integer | float | string $before, integer | float | string $after, string $reason = '', integer | float | string $cost ) : boolean | Model Creates a new stock movement record.
getMovementById ( integer | string $id ) : null | Model Retrieves a movement by the specified ID.
processMoveOperation ( Model $location ) : boolean Processes the stock moving from it's current location, to the specified location.
processPutOperation ( integer | float | string $putting, string $reason = '', integer | float | string $cost ) Processes adding quantity to current stock.
processRecursiveRollbackOperation ( Model $movement ) : array Processes a recursive rollback operation.
processRollbackOperation ( Model $movement, boolean $recursive = false ) Processes a single rollback operation.
processTakeOperation ( integer | float | string $taking, string $reason = '', integer | float | string $cost ) Processes removing quantity from the current stock.
processUpdateQuantityOperation ( integer | float | string $quantity, string $reason = '', integer | float | string $cost ) Processes a quantity update operation.
reverseCost ( ) Reverses the cost of a movement.
rollbackCostEnabled ( ) : boolean Returns true/false from the configuration file determining whether or not to rollback costs when a rollback occurs on a stock.
setCost ( integer | float | string $cost ) Sets the cost attribute.
setReason ( string $reason = '' ) Sets the reason attribute.

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

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

Alias for put function.
public add ( integer | float | string $quantity, string $reason = '', integer | float | string $cost )
$quantity integer | float | string
$reason string
$cost integer | float | string

allowDuplicateMovementsEnabled() защищенный Метод

Returns true/false from the configuration file determining whether or not stock movements can have the same before and after quantities.
protected allowDuplicateMovementsEnabled ( ) : boolean
Результат boolean

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

Overrides the models boot function to set the user ID automatically to every new record.
public static bootInventoryStockTrait ( )

generateStockMovement() защищенный Метод

Creates a new stock movement record.
protected generateStockMovement ( integer | float | string $before, integer | float | string $after, string $reason = '', integer | float | string $cost ) : boolean | Model
$before integer | float | string
$after integer | float | string
$reason string
$cost integer | float | string
Результат boolean | Illuminate\Database\Eloquent\Model

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

Returns the last movement on the current stock record.
public getLastMovement ( ) : boolean | Model
Результат boolean | Illuminate\Database\Eloquent\Model

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

Returns a movement depending on the specified argument. If an object is supplied, it is checked if it is an instance of an eloquent model. If a numeric value is entered, it is retrieved by it's ID.
public getMovement ( integer | string | Model $movement ) : mixed
$movement integer | string | Illuminate\Database\Eloquent\Model
Результат mixed

getMovementById() защищенный Метод

Retrieves a movement by the specified ID.
protected getMovementById ( integer | string $id ) : null | Model
$id integer | string
Результат null | Illuminate\Database\Eloquent\Model

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

Throws NotEnoughStockException otherwise.
public hasEnoughStock ( integer | float | string $quantity ) : boolean
$quantity integer | float | string
Результат boolean

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

The belongsTo item relationship.
abstract public item ( ) : BelongsTo
Результат Illuminate\Database\Eloquent\Relations\BelongsTo

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

The hasOne location relationship.
abstract public location ( ) : Illuminate\Database\Eloquent\Relations\HasOne
Результат Illuminate\Database\Eloquent\Relations\HasOne

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

Moves a stock to the specified location.
public moveTo ( Model $location ) : boolean
$location Illuminate\Database\Eloquent\Model
Результат boolean

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

The hasMany movements relationship.
abstract public movements ( ) : Illuminate\Database\Eloquent\Relations\HasMany
Результат Illuminate\Database\Eloquent\Relations\HasMany

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

Creates and returns a new un-saved stock transaction instance with the current stock ID attached.
public newTransaction ( string $name = '' ) : Model
$name string
Результат Illuminate\Database\Eloquent\Model

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

Generates a stock movement after a stock is created.
public postCreate ( ) : void
Результат void

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

Generates a stock movement after a stock is updated.
public postUpdate ( ) : void
Результат void

processMoveOperation() защищенный Метод

Processes the stock moving from it's current location, to the specified location.
protected processMoveOperation ( Model $location ) : boolean
$location Illuminate\Database\Eloquent\Model
Результат boolean

processPutOperation() защищенный Метод

Processes adding quantity to current stock.
protected processPutOperation ( integer | float | string $putting, string $reason = '', integer | float | string $cost )
$putting integer | float | string
$reason string
$cost integer | float | string

processRecursiveRollbackOperation() защищенный Метод

Processes a recursive rollback operation.
protected processRecursiveRollbackOperation ( Model $movement ) : array
$movement Illuminate\Database\Eloquent\Model
Результат array

processRollbackOperation() защищенный Метод

Processes a single rollback operation.
protected processRollbackOperation ( Model $movement, boolean $recursive = false )
$movement Illuminate\Database\Eloquent\Model
$recursive boolean

processTakeOperation() защищенный Метод

Processes removing quantity from the current stock.
protected processTakeOperation ( integer | float | string $taking, string $reason = '', integer | float | string $cost )
$taking integer | float | string
$reason string
$cost integer | float | string

processUpdateQuantityOperation() защищенный Метод

Processes a quantity update operation.
protected processUpdateQuantityOperation ( integer | float | string $quantity, string $reason = '', integer | float | string $cost )
$quantity integer | float | string
$reason string
$cost integer | float | string

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

Processes a 'put' operation on the current stock.
public put ( integer | float | string $quantity, string $reason = '', integer | float | string $cost )
$quantity integer | float | string
$reason string
$cost integer | float | string

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

Removes the specified quantity from the current stock.
public remove ( integer | float | string $quantity, string $reason = '', integer | float | string $cost )
$quantity integer | float | string
$reason string
$cost integer | float | string

reverseCost() защищенный Метод

Reverses the cost of a movement.
protected reverseCost ( )

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

Rolls back the last movement, or the movement specified. If recursive is set to true, it will rollback all movements leading up to the movement specified.
public rollback ( mixed $movement = null, boolean $recursive = false )
$movement mixed
$recursive boolean

rollbackCostEnabled() защищенный Метод

Returns true/false from the configuration file determining whether or not to rollback costs when a rollback occurs on a stock.
protected rollbackCostEnabled ( ) : boolean
Результат boolean

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

Rolls back a specific movement.
public rollbackMovement ( mixed $movement, boolean $recursive = false )
$movement mixed
$recursive boolean

setCost() защищенный Метод

Sets the cost attribute.
protected setCost ( integer | float | string $cost )
$cost integer | float | string

setReason() защищенный Метод

Sets the reason attribute.
protected setReason ( string $reason = '' )
$reason string

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

Processes a 'take' operation on the current stock.
public take ( integer | float | string $quantity, string $reason = '', integer | float | string $cost )
$quantity integer | float | string
$reason string
$cost integer | float | string

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

The hasMany transactions relationship.
abstract public transactions ( ) : Illuminate\Database\Eloquent\Relations\HasMany
Результат Illuminate\Database\Eloquent\Relations\HasMany

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

Performs a quantity update. Automatically determining depending on the quantity entered if stock is being taken or added.
public updateQuantity ( integer | float | string $quantity, string $reason = '', integer | float | string $cost )
$quantity integer | float | string
$reason string
$cost integer | float | string

Описание свойств

$beforeQuantity защищенное свойство

Stores the quantity before an update.
protected int|float|string $beforeQuantity
Результат integer | float | string

$cost публичное свойство

Stores the cost for updating a stock.
public int|float|string $cost
Результат integer | float | string

$reason публичное свойство

Stores the reason for updating / creating a stock.
public string $reason
Результат string