I have a table in my database called stocks. In the table, i have two columns product_id, supplied among other columns. So when i get a supply, i add the entries to my table and the table looking like so;
product_id supplied
1 10
2 15
5 5
2 12
4 10
5 12
2 5
1 12
4 12
Now i want to use laravel eloquent to select the stock by the product_id, returning the total number of items in stock like this;
product_id total_in_stock
1 22
2 32
4 22
5 17
Any assistance will be appreciated.
from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2JCJEws
via IFTTT
Aucun commentaire:
Enregistrer un commentaire