Laravelshoppingcart: FatalErrorException in CartController.php line 15: Class 'App\Http\Controllers\Cart' not found

Created on 27 Dec 2015  路  4Comments  路  Source: Crinsane/LaravelShoppingcart

I'm sorry I'm pretty new to Laravel but can't get this to work.
The error I'm getting is:

FatalErrorException in CartController.php line 15: Class 'App\Http\Controllers\Cart' not found

My CartController.php:
'''

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;

class CartController extends Controller
{
public function addToCart()
{
Cart::add('192ao12', 'Product 1', 1, 9.99);
Cart::add('1239ad0', 'Product 2', 2, 5.95, array('size' => 'large'));

    return 'Added';
}

public function viewCart()
{
    return view('pages.cart');
}

}
'''

I think I need to add a 'use' but how exactly?

Thanks in advance

Most helpful comment

You indeed have to use the Cart namespace. Simply "use Cart;"

All 4 comments

You indeed have to use the Cart namespace. Simply "use Cart;"

thanks

thanks

Thanks, that was helpful...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ellgibug picture ellgibug  路  5Comments

nareshbabu557 picture nareshbabu557  路  8Comments

yansentan picture yansentan  路  6Comments

wasid picture wasid  路  8Comments

muhammadatallah picture muhammadatallah  路  7Comments