Can you help me how to decrement after doing a checkout. So far this is the only idea I have but it shows an error called "Object of class Illuminate\Database\Eloquent\Collection could not be converted to number ". Thank you for the reply. Also I am using the one with session.
Note. I edit and put another image for more clearer explanation and here is the code
public function postCheckout(Request $request){
$books = Product::all();
if (!Session::has('cart')){
return view('shop.shoppingcart');
}
$oldCart = Session::get('cart');
$cart = new Cart($oldCart);
$order = new Order();
$order->cart = serialize($cart);
$order->address = $request->input('address');
$order->name = $request->input('name');
Auth::user()->orders()->save($order);
$q=$cart->totalQty;
$r=$books-$q;
Product::table('books')
->where('id',$id)
->update(array('quantity' => $r));
Session::forget('cart');
return redirect("home");
}
And the error is "Object of class Illuminate\Database\Eloquent\Collection could not be converted to number"
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3gySLuk
via IFTTT
Aucun commentaire:
Enregistrer un commentaire