PHP Trait Stevebauman\Inventory\Traits\AssemblyTrait

显示文件 Open project: stevebauman/inventory

Protected Properties

Property Type Description
$assemblyCacheKey string The items assembly cache key.

Public Methods

Method Description
addAssemblyItem ( Model $part, integer | float | string $quantity = 1, array $extra = [] ) Adds an item to the current assembly.
addAssemblyItems ( array $parts, integer | float | string $quantity = 1, array $extra = [] ) : integer Adds multiple parts to the current items assembly.
assemblies ( ) : Illuminate\Database\Eloquent\Relations\BelongsToMany The hasMany assemblies relationship.
assembliesRecursive ( ) : Illuminate\Database\Eloquent\Relations\BelongsToMany The belongsToMany recursive assemblies relationship.
forgetCachedAssemblyItems ( ) : boolean Removes the current items assembly items from the cache.
getAssemblyItems ( boolean $recursive = true ) : Illuminate\Database\Eloquent\Collection Returns all of the assemblies items. If recursive is true, the entire nested assemblies collection is returned.
getAssemblyItemsList ( boolean $recursive = true, integer $depth ) : array Returns all of the assemblies items in an easy to work with array.
getCachedAssemblyItems ( ) : boolean | Illuminate\Database\Eloquent\Collection Returns the current cached items assembly if it exists inside the cache. Returns false otherwise.
hasCachedAssemblyItems ( ) : boolean Returns true / false if the current item has a cached assembly.
makeAssembly ( ) Makes the current item an assembly.
removeAssemblyItem ( integer | string | Model $part ) : boolean Removes the specified part from the current items assembly.
removeAssemblyItems ( array $parts ) : integer Removes multiple parts from the current items assembly.
scopeAssembly ( Builder $query ) : mixed Scopes the current query to only retrieve inventory items that are an assembly.
updateAssemblyItem ( integer | string | Model $part, integer | float | string $quantity = 1, array $extra = [] ) Updates the inserted parts quantity for the current item's assembly.
updateAssemblyItems ( array $parts, integer | float | string $quantity, array $extra = [] ) : integer Updates multiple parts with the specified quantity.

Protected Methods

Method Description
getAssemblyCacheKey ( ) : string Returns the current items assemblies cache key.
validatePart ( Model $part ) : boolean Validates that the inserted parts assembly does not contain the current item. This prevents infinite recursion.
validatePartAgainstList ( mixed $value, integer | string $key ) Validates the value and key of the values from the assemblies item list to verify that it does not equal the current items ID.

Method Details

addAssemblyItem() public method

Adds an item to the current assembly.
public addAssemblyItem ( Model $part, integer | float | string $quantity = 1, array $extra = [] )
$part Illuminate\Database\Eloquent\Model
$quantity integer | float | string
$extra array

addAssemblyItems() public method

Adds multiple parts to the current items assembly.
public addAssemblyItems ( array $parts, integer | float | string $quantity = 1, array $extra = [] ) : integer
$parts array
$quantity integer | float | string
$extra array
return integer

assemblies() abstract public method

The hasMany assemblies relationship.
abstract public assemblies ( ) : Illuminate\Database\Eloquent\Relations\BelongsToMany
return Illuminate\Database\Eloquent\Relations\BelongsToMany

assembliesRecursive() public method

The belongsToMany recursive assemblies relationship.
public assembliesRecursive ( ) : Illuminate\Database\Eloquent\Relations\BelongsToMany
return Illuminate\Database\Eloquent\Relations\BelongsToMany

forgetCachedAssemblyItems() public method

Removes the current items assembly items from the cache.

getAssemblyCacheKey() protected method

Returns the current items assemblies cache key.
protected getAssemblyCacheKey ( ) : string
return string

getAssemblyItems() public method

Returns all of the assemblies items. If recursive is true, the entire nested assemblies collection is returned.
public getAssemblyItems ( boolean $recursive = true ) : Illuminate\Database\Eloquent\Collection
$recursive boolean
return Illuminate\Database\Eloquent\Collection

getAssemblyItemsList() public method

Returns all of the assemblies items in an easy to work with array.
public getAssemblyItemsList ( boolean $recursive = true, integer $depth ) : array
$recursive boolean
$depth integer
return array

getCachedAssemblyItems() public method

Returns the current cached items assembly if it exists inside the cache. Returns false otherwise.
public getCachedAssemblyItems ( ) : boolean | Illuminate\Database\Eloquent\Collection
return boolean | Illuminate\Database\Eloquent\Collection

hasCachedAssemblyItems() public method

Returns true / false if the current item has a cached assembly.
public hasCachedAssemblyItems ( ) : boolean
return boolean

makeAssembly() public method

Makes the current item an assembly.
public makeAssembly ( )

removeAssemblyItem() public method

Removes the specified part from the current items assembly.
public removeAssemblyItem ( integer | string | Model $part ) : boolean
$part integer | string | Illuminate\Database\Eloquent\Model
return boolean

removeAssemblyItems() public method

Removes multiple parts from the current items assembly.
public removeAssemblyItems ( array $parts ) : integer
$parts array
return integer

scopeAssembly() public method

Scopes the current query to only retrieve inventory items that are an assembly.
public scopeAssembly ( Builder $query ) : mixed
$query Illuminate\Database\Query\Builder
return mixed

updateAssemblyItem() public method

Updates the inserted parts quantity for the current item's assembly.
public updateAssemblyItem ( integer | string | Model $part, integer | float | string $quantity = 1, array $extra = [] )
$part integer | string | Illuminate\Database\Eloquent\Model
$quantity integer | float | string
$extra array

updateAssemblyItems() public method

Updates multiple parts with the specified quantity.
public updateAssemblyItems ( array $parts, integer | float | string $quantity, array $extra = [] ) : integer
$parts array
$quantity integer | float | string
$extra array
return integer

validatePart() protected method

Validates that the inserted parts assembly does not contain the current item. This prevents infinite recursion.
protected validatePart ( Model $part ) : boolean
$part Illuminate\Database\Eloquent\Model
return boolean

validatePartAgainstList() protected method

Validates the value and key of the values from the assemblies item list to verify that it does not equal the current items ID.
protected validatePartAgainstList ( mixed $value, integer | string $key )
$value mixed
$key integer | string

Property Details

$assemblyCacheKey protected_oe property

The items assembly cache key.
protected string $assemblyCacheKey
return string