I have an Laravel store with Product Quantity in my DB.
The Quantity left what Members see :
Quantity : {{$product->instock}}
Product Create :
<input type="number" name="instock" id="instock" class="productcreate" value="{{old('instock')}}" placeholder="Enter Your Quantity"> in Stock
Controller:
if ($request->instock == null) {
session()->flash('errormessage','Quantity is required');
return redirect()->back()->withInput();
}
How can I reduce my Quantity for every Sold item? Example I have 90 Items right now in stock. An Member buy one Item and the Quantity Reduce to 89 Items right now in Quantity: {{$product->instock}}
What code must I add in my Controller for it?
Thanks
When someone makes a purchase use the decrement() method. Something like:
Product::decrement('instock', $itemsPurchased);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With