PHP Trait Stevebauman\Inventory\Traits\InventoryStockTrait

Inheritance: use trait CommonMethodsTrait
Afficher le fichier Open project: stevebauman/inventory

Méthodes publiques

Свойство Type Description
$cost integer | float | string Stores the cost for updating a stock.
$reason string Stores the reason for updating / creating a stock.

Protected Properties

Свойство Type Description
$beforeQuantity integer | float | string Stores the quantity before an update.

Méthodes publiques

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

Méthodes protégées

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

Method Details

add() public méthode

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() protected méthode

Returns true/false from the configuration file determining whether or not stock movements can have the same before and after quantities.
protected allowDuplicateMovementsEnabled ( ) : boolean
Résultat boolean

bootInventoryStockTrait() public static méthode

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

generateStockMovement() protected méthode

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
Résultat boolean | Illuminate\Database\Eloquent\Model

getLastMovement() public méthode

Returns the last movement on the current stock record.
public getLastMovement ( ) : boolean | Model
Résultat boolean | Illuminate\Database\Eloquent\Model

getMovement() public méthode

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

getMovementById() protected méthode

Retrieves a movement by the specified ID.
protected getMovementById ( integer | string $id ) : null | Model
$id integer | string
Résultat null | Illuminate\Database\Eloquent\Model

hasEnoughStock() public méthode

Throws NotEnoughStockException otherwise.
public hasEnoughStock ( integer | float | string $quantity ) : boolean
$quantity integer | float | string
Résultat boolean

item() abstract public méthode

The belongsTo item relationship.
abstract public item ( ) : BelongsTo
Résultat Illuminate\Database\Eloquent\Relations\BelongsTo

location() abstract public méthode

The hasOne location relationship.
abstract public location ( ) : Illuminate\Database\Eloquent\Relations\HasOne
Résultat Illuminate\Database\Eloquent\Relations\HasOne

moveTo() public méthode

Moves a stock to the specified location.
public moveTo ( Model $location ) : boolean
$location Illuminate\Database\Eloquent\Model
Résultat boolean

movements() abstract public méthode

The hasMany movements relationship.
abstract public movements ( ) : Illuminate\Database\Eloquent\Relations\HasMany
Résultat Illuminate\Database\Eloquent\Relations\HasMany

newTransaction() public méthode

Creates and returns a new un-saved stock transaction instance with the current stock ID attached.
public newTransaction ( string $name = '' ) : Model
$name string
Résultat Illuminate\Database\Eloquent\Model

postCreate() public méthode

Generates a stock movement after a stock is created.
public postCreate ( ) : void
Résultat void

postUpdate() public méthode

Generates a stock movement after a stock is updated.
public postUpdate ( ) : void
Résultat void

processMoveOperation() protected méthode

Processes the stock moving from it's current location, to the specified location.
protected processMoveOperation ( Model $location ) : boolean
$location Illuminate\Database\Eloquent\Model
Résultat boolean

processPutOperation() protected méthode

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() protected méthode

Processes a recursive rollback operation.
protected processRecursiveRollbackOperation ( Model $movement ) : array
$movement Illuminate\Database\Eloquent\Model
Résultat array

processRollbackOperation() protected méthode

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

processTakeOperation() protected méthode

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() protected méthode

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() public méthode

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() public méthode

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() protected méthode

Reverses the cost of a movement.
protected reverseCost ( )

rollback() public méthode

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() protected méthode

Returns true/false from the configuration file determining whether or not to rollback costs when a rollback occurs on a stock.
protected rollbackCostEnabled ( ) : boolean
Résultat boolean

rollbackMovement() public méthode

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

setCost() protected méthode

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

setReason() protected méthode

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

take() public méthode

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() abstract public méthode

The hasMany transactions relationship.
abstract public transactions ( ) : Illuminate\Database\Eloquent\Relations\HasMany
Résultat Illuminate\Database\Eloquent\Relations\HasMany

updateQuantity() public méthode

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

Property Details

$beforeQuantity protected_oe property

Stores the quantity before an update.
protected int|float|string $beforeQuantity
Résultat integer | float | string

$cost public_oe property

Stores the cost for updating a stock.
public int|float|string $cost
Résultat integer | float | string

$reason public_oe property

Stores the reason for updating / creating a stock.
public string $reason
Résultat string