appstract / laravel-stock Goto Github PK
View Code? Open in Web Editor NEWKeep stock for Eloquent models
License: MIT License
Keep stock for Eloquent models
License: MIT License
The stock
method of the HasStock trait returns the current stock value if no date is given.
It gets the value by summing all the stock mutations the stockable model has.
It works without issues, however if there are thousands of stock mutations and it's required to have a page that shows hundreads of products and their stock, such SQL query might be quite expensive.
I think it would be useful to have an option to save the current stock after a stock mutation, so when calling the stock method without a date, it just returns the value, without the need to sum everything.
Would a PR for this feature be welcome?
I'm creating an application which uses variants, what would be the suggested way to handle stock of main product and variants using your package?
For example if I used a table layout like this
products
products_variants
products_variants_options
Where variants are like size and color
variants options are small, medium, large and blue, red, white
Thanks
How could a stock history be implemented to keep track of how many sales or additions were made to a given product?
Would it be possible to add warehouse support? Maybe like an extra pivot model so like:
Book + Warehouse = the stock
Add a notInStock method + tests
Using property (int) $this->stockMutations instead of method $this->stockMutations() to avoid eager loading problem.
laravel-stock/src/HasStock.php
Line 41 in 216ab0f
Example :
Book:with('stock')->get();
OR
Book:with('stocks')->get();
[translated from google]
Hello. I'm wondering why the package only consider amount as integer. If we consider a supermarket selling meat in kilograms... someone could buy 2.5 kilograms in this case for instance, the package will not suit.
As a developer I want to be able to use MongoDB instead of a SQL database.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.