Closed KishwerWali54 closed 2 years ago
How do you use Cart in your controller? If you use it without a use directive, i.e. the alias, you will have to use the global namespace like so:
\Cart::
Without the prefix slash you would use class Cart
from within your Controller namespace, as Cart::
would become \App\Http\Controllers\Cart::
, where it does not exist.
My Provider is:
Gloudemans\Shoppingcart\ShoppingcartServiceProvider::class,
and Alias is:
'Cart' => Gloudemans\Shoppingcart\Facades\Cart::class,
and My Controller is:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Cart;
class CartController extends Controller
{
//
public function add()
{
Cart::add('192ao12', 'Product 1', 1, 9.99);
$cart= Cart::content();
return back()->with('feedback','Item is added into cart');
}
}
This is not helpfull
Hello,
I am facing this error Class "Cart" not found while using it in the controller.
I have given the Providers and aliases correctly which are as followinf respectively:
Gloudemans\Shoppingcart\ShoppingcartServiceProvider::class,
'Cart' => Gloudemans\Shoppingcart\Facades\Cart::class,
And I also mentioned Use Cart at the top. Can anyone help? p.s. I am using Laravel 8