Download the PHP package appstract/laravel-stock without Composer
On this page you can find all versions of the php package appstract/laravel-stock. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download appstract/laravel-stock
More information about appstract/laravel-stock
Files in appstract/laravel-stock
Package laravel-stock
Short Description Keep stock for Eloquent models
License MIT
Homepage https://github.com/appstract/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="Appstract\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.
Usage
Adding the HasStock
trait will enable stock functionality on the Model.
Basic mutations
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).
Current stock
Get the current stock value (on a certain date).
Stock arguments
Add a description and/or reference model to de StockMutation.
Query Scopes
It is also possible to query based on stock.
Testing
Contributing
Contributions are welcome, thanks to y'all :)
About Appstract
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.