Download the PHP package inquid/laravel-stock without Composer
On this page you can find all versions of the php package inquid/laravel-stock. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download inquid/laravel-stock
More information about inquid/laravel-stock
Files in inquid/laravel-stock
Package laravel-stock
Short Description Keep stock for Eloquent models
License MIT
Homepage https://github.com/inquid/laravel-stock
Informations about the package laravel-stock
Laravel Stock
Keep stock for Eloquent models. This package will track stock mutations for your models. You can increase, decrease, clear and set stock. It's also possible to check if a model is in stock (on a certain date/time).
Installation
You can install the package via composer:
By running php artisan vendor:publish --provider="Inquid\Stock\StockServiceProvider"
in your project all files for this package will be published. Run php artisan migrate
to migrate the table. There will now be a stock_mutations
table in your database.
The configuration file looks this:
Usage
Adding the HasStock
trait will enable stock functionality on the Model.
Note: If you need to use a custom Model for example for MongoDB you can update the model to use in the config file
stock.php
.
Basic mutations
With warehouse support
Clearing stock
It's also possible to clear the stock and directly setting a new value.
Setting stock
It is possible to set stock. This will create a new mutation with the difference between the old and new value.
Check if model is in stock
It's also possible to check if a product is in stock (with a minimal value).
With warehouse
Current stock
Get the current stock value (on a certain date).
Note: If you are using MongoDb you need to set the date class in the config file.
'special_date_class' => \MongoDB\BSON\UTCDateTime::class,
Current stock in specific warehouse
Get the current stock value (on a certain date) in specific warehouse.
Move between warehouses
Move amount from source warehouse to destination warehouse.
Stock arguments
Add a description and/or reference model to de StockMutation.
With warehouse
Query Scopes
It is also possible to query based on stock.
Testing
Contributing
Contributions are welcome, thanks to y'all :)
About Appstract (Original Author)
Appstract is a small team from The Netherlands. We create (open source) tools for Web Developers and write about related subjects on Medium. You can follow us on Twitter, buy us a beer or support us on Patreon.
License
The MIT License (MIT). Please see License File for more information.