[英]How to clear all data from shopping cart derryl decode in laravel
Cart::clear()
is not working correctly. Cart::clear()
无法正常工作。
how can I erase all data from my cart?如何删除购物车中的所有数据? it says Non-static method Darryldecode\Cart\Cart::clear() should not be called statically
它说不Non-static method Darryldecode\Cart\Cart::clear() should not be called statically
Used \Cart::clear()
.使用\Cart::clear()
。
It works for me.这个对我有用。
Heading section标题部分
namespace App\Http\Controllers;
use App\Models\DatabaseStorageModel;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Darryldecode\Cart\CartCondition;
Function Section Function款
public function clear()
{
$userId = Auth::id();
\Cart::session($userId)->clear(); // use user session
return redirect()->route('cart.index', ['message' => 'cart reset to empty']);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.