PHP Trait Stevebauman\Inventory\Traits\InventoryTrait

Inheritance: use trait CommonMethodsTrait
Mostrar archivo Open project: stevebauman/inventory

Public Methods

Method Description
addToLocation ( integer | float | string $quantity, Model $location, string $reason = '', integer | float | string $cost ) : array Alias for the put function.
addToManyLocations ( integer | float | string $quantity, array $locations = [], string $reason = '', integer | float | string $cost ) : array Alias for the putToMany function.
bootInventoryTrait ( ) Overrides the models boot function to set the user ID automatically to every new record.
category ( ) : Illuminate\Database\Eloquent\Relations\HasOne The hasOne category relationship.
createSku ( string $code, boolean $overwrite = false ) : mixed | boolean Creates an SKU with the specified code. If overwrite is true, the current items SKU will be deleted if it exists before creating then SKU. If overwrite is false but the item has an SKU, an exception is thrown.
createStockOnLocation ( integer | float | string $quantity, Model $location, string $reason = '', integer | float | string $cost, string $aisle = null, string $row = null, string $bin = null ) : Model Creates a stock record to the current inventory item.
findBySku ( string $sku ) : boolean Returns an item record by the specified SKU code.
generateSku ( ) : boolean | mixed Generates an item SKU record.
getMetricSymbol ( ) : string | null Returns the inventory's metric symbol.
getSku ( ) : null | string Returns the item's SKU.
getSkuCodeAttribute ( ) : null | string Laravel accessor for the current items SKU.
getStockFromLocation ( Model $location ) : mixed Retrieves an inventory stock from a given location.
getTotalStock ( ) : integer | float Returns the total sum of the current item stock.
hasCategory ( ) : boolean Returns true/false if the current item has a category.
hasMetric ( ) : boolean Returns true/false if the inventory has a metric present.
hasSku ( ) : boolean Returns true/false if the current item has an SKU.
isInStock ( ) : boolean Returns true/false if the inventory has stock.
metric ( ) : Illuminate\Database\Eloquent\Relations\HasOne The hasOne metric relationship.
moveStock ( Model $fromLocation, Model $toLocation ) : mixed Moves a stock from one location to another.
newStockOnLocation ( Model $location ) : Model Instantiates a new stock on the specified location on the current item.
putToLocation ( integer | float | string $quantity, Model $location, string $reason = '', integer | float | string $cost ) : array Puts the specified amount ($quantity) of stock into the specified stock location.
putToManyLocations ( integer | float | string $quantity, array $locations = [], string $reason = '', integer | float | string $cost ) : array Puts the specified amount ($quantity) of stock into the specified stock locations.
regenerateSku ( ) : boolean | mixed Regenerates the current items SKU by deleting its current SKU and creating another. This will also generate an SKU if one does not exist.
removeFromLocation ( integer | float | string $quantity, $location, string $reason = '' ) : array Alias for the take function.
removeFromManyLocations ( integer | float | string $quantity, array $locations = [], string $reason = '' ) : array Alias for the takeFromMany function.
sku ( ) : Illuminate\Database\Eloquent\Relations\HasOne The hasOne SKU relationship.
stocks ( ) : Illuminate\Database\Eloquent\Relations\HasMany The hasMany stocks relationship.
suppliers ( ) : Illuminate\Database\Eloquent\Relations\BelongsToMany The belongsToMany suppliers relationship.
takeFromLocation ( integer | float | string $quantity, Model $location, string $reason = '' ) : array Takes the specified amount ($quantity) of stock from specified stock location.
takeFromManyLocations ( integer | float | string $quantity, array $locations = [], string $reason = '' ) : array Takes the specified amount ($quantity) of stock from the specified stock locations.
updateSku ( string $code, null $sku = null ) : mixed | boolean Updates the items current SKU or the SKU supplied with the specified code.

Protected Methods

Method Description
processSkuGeneration ( integer | string $inventoryId, string $code ) : boolean | mixed Processes an SKU generation covered by database transactions.
processSkuUpdate ( Model $sku, string $code ) : mixed | boolean Processes updating the specified SKU record with the specified code.
skusEnabled ( ) : mixed Returns the configuration option for the enablement of automatic SKU generation.

Method Details

addToLocation() public method

Alias for the put function.
public addToLocation ( integer | float | string $quantity, Model $location, string $reason = '', integer | float | string $cost ) : array
$quantity integer | float | string
$location Illuminate\Database\Eloquent\Model
$reason string
$cost integer | float | string
return array

addToManyLocations() public method

Alias for the putToMany function.
public addToManyLocations ( integer | float | string $quantity, array $locations = [], string $reason = '', integer | float | string $cost ) : array
$quantity integer | float | string
$locations array
$reason string
$cost integer | float | string
return array

bootInventoryTrait() public static method

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

category() abstract public method

The hasOne category relationship.
abstract public category ( ) : Illuminate\Database\Eloquent\Relations\HasOne
return Illuminate\Database\Eloquent\Relations\HasOne

createSku() public method

Creates an SKU with the specified code. If overwrite is true, the current items SKU will be deleted if it exists before creating then SKU. If overwrite is false but the item has an SKU, an exception is thrown.
public createSku ( string $code, boolean $overwrite = false ) : mixed | boolean
$code string
$overwrite boolean
return mixed | boolean

createStockOnLocation() public method

Creates a stock record to the current inventory item.
public createStockOnLocation ( integer | float | string $quantity, Model $location, string $reason = '', integer | float | string $cost, string $aisle = null, string $row = null, string $bin = null ) : Model
$quantity integer | float | string
$location Illuminate\Database\Eloquent\Model
$reason string
$cost integer | float | string
$aisle string
$row string
$bin string
return Illuminate\Database\Eloquent\Model

findBySku() public static method

Returns an item record by the specified SKU code.
public static findBySku ( string $sku ) : boolean
$sku string
return boolean

generateSku() public method

If an item already has an SKU, the SKU record will be returned. If an item does not have a category, it will return false.
public generateSku ( ) : boolean | mixed
return boolean | mixed

getMetricSymbol() public method

Returns the inventory's metric symbol.
public getMetricSymbol ( ) : string | null
return string | null

getSku() public method

Returns the item's SKU.
public getSku ( ) : null | string
return null | string

getSkuCodeAttribute() public method

Laravel accessor for the current items SKU.
public getSkuCodeAttribute ( ) : null | string
return null | string

getStockFromLocation() public method

Retrieves an inventory stock from a given location.
public getStockFromLocation ( Model $location ) : mixed
$location Illuminate\Database\Eloquent\Model
return mixed

getTotalStock() public method

Returns the total sum of the current item stock.
public getTotalStock ( ) : integer | float
return integer | float

hasCategory() public method

Returns true/false if the current item has a category.
public hasCategory ( ) : boolean
return boolean

hasMetric() public method

Returns true/false if the inventory has a metric present.
public hasMetric ( ) : boolean
return boolean

hasSku() public method

Returns true/false if the current item has an SKU.
public hasSku ( ) : boolean
return boolean

isInStock() public method

Returns true/false if the inventory has stock.
public isInStock ( ) : boolean
return boolean

metric() abstract public method

The hasOne metric relationship.
abstract public metric ( ) : Illuminate\Database\Eloquent\Relations\HasOne
return Illuminate\Database\Eloquent\Relations\HasOne

moveStock() public method

Moves a stock from one location to another.
public moveStock ( Model $fromLocation, Model $toLocation ) : mixed
$fromLocation Illuminate\Database\Eloquent\Model
$toLocation Illuminate\Database\Eloquent\Model
return mixed

newStockOnLocation() public method

Instantiates a new stock on the specified location on the current item.
public newStockOnLocation ( Model $location ) : Model
$location Illuminate\Database\Eloquent\Model
return Illuminate\Database\Eloquent\Model

processSkuGeneration() protected method

Processes an SKU generation covered by database transactions.
protected processSkuGeneration ( integer | string $inventoryId, string $code ) : boolean | mixed
$inventoryId integer | string
$code string
return boolean | mixed

processSkuUpdate() protected method

Processes updating the specified SKU record with the specified code.
protected processSkuUpdate ( Model $sku, string $code ) : mixed | boolean
$sku Illuminate\Database\Eloquent\Model
$code string
return mixed | boolean

putToLocation() public method

Puts the specified amount ($quantity) of stock into the specified stock location.
public putToLocation ( integer | float | string $quantity, Model $location, string $reason = '', integer | float | string $cost ) : array
$quantity integer | float | string
$location Illuminate\Database\Eloquent\Model
$reason string
$cost integer | float | string
return array

putToManyLocations() public method

Puts the specified amount ($quantity) of stock into the specified stock locations.
public putToManyLocations ( integer | float | string $quantity, array $locations = [], string $reason = '', integer | float | string $cost ) : array
$quantity integer | float | string
$locations array
$reason string
$cost integer | float | string
return array

regenerateSku() public method

Regenerates the current items SKU by deleting its current SKU and creating another. This will also generate an SKU if one does not exist.
public regenerateSku ( ) : boolean | mixed
return boolean | mixed

removeFromLocation() public method

Alias for the take function.
public removeFromLocation ( integer | float | string $quantity, $location, string $reason = '' ) : array
$quantity integer | float | string
$location
$reason string
return array

removeFromManyLocations() public method

Alias for the takeFromMany function.
public removeFromManyLocations ( integer | float | string $quantity, array $locations = [], string $reason = '' ) : array
$quantity integer | float | string
$locations array
$reason string
return array

sku() abstract public method

The hasOne SKU relationship.
abstract public sku ( ) : Illuminate\Database\Eloquent\Relations\HasOne
return Illuminate\Database\Eloquent\Relations\HasOne

skusEnabled() protected method

Returns the configuration option for the enablement of automatic SKU generation.
protected skusEnabled ( ) : mixed
return mixed

stocks() abstract public method

The hasMany stocks relationship.
abstract public stocks ( ) : Illuminate\Database\Eloquent\Relations\HasMany
return Illuminate\Database\Eloquent\Relations\HasMany

suppliers() abstract public method

The belongsToMany suppliers relationship.
abstract public suppliers ( ) : Illuminate\Database\Eloquent\Relations\BelongsToMany
return Illuminate\Database\Eloquent\Relations\BelongsToMany

takeFromLocation() public method

Takes the specified amount ($quantity) of stock from specified stock location.
public takeFromLocation ( integer | float | string $quantity, Model $location, string $reason = '' ) : array
$quantity integer | float | string
$location Illuminate\Database\Eloquent\Model
$reason string
return array

takeFromManyLocations() public method

Takes the specified amount ($quantity) of stock from the specified stock locations.
public takeFromManyLocations ( integer | float | string $quantity, array $locations = [], string $reason = '' ) : array
$quantity integer | float | string
$locations array
$reason string
return array

updateSku() public method

Updates the items current SKU or the SKU supplied with the specified code.
public updateSku ( string $code, null $sku = null ) : mixed | boolean
$code string
$sku null
return mixed | boolean