PHP 트레잇 Stevebauman\Inventory\Traits\InventoryStockTrait

상속: use trait CommonMethodsTrait
파일 보기 프로젝트 열기: stevebauman/inventory

공개 프로퍼티들

프로퍼티 타입 설명
$cost integer | float | string Stores the cost for updating a stock.
$reason string Stores the reason for updating / creating a stock.

보호된 프로퍼티들

프로퍼티 타입 설명
$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.

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