syntax error, unexpected 'class' (T_CLASS) in Laravel Cart

Posted 3 months ago by WebbieWorks

I am trying to install a this shopping cart using Laravel but I am getting an error and I cannot figure it out. I have triple checked all my routes and they all seem to be what they should be. I have been searching everywhere for this, but what I can find, it actually shows where the error is, like "unexpected error in (error location).

syntax error, unexpected 'class' (T_CLASS)

This is my QuoteController (some code removed for space)

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Product;
use Gloudemans\Shoppingcart\Facades\Cart;


class QuoteController extends Controller
{
public function index()
    {
        return view('quote');
    }
public function store(Request $request)
    {
        Quote::add($request->$id, $request->name)
          ->associate('App\Product');

        return redirect()->route('quote.index')->with('success_message', 'Item was add to quote!');
    }
}

My routes in web.php look correct.

Route::get('/quote.php', '[email protected]')->name('quote.index');
Route::post('/quote.php', '[email protected]')->name('quote.store');

Also, here is the code for the button.

<form action="{{ route('quote.store') }}" method="POST">
                {{ csrf_field() }}
                <input type="hidden" name="id" value="{{ $product->id }}">
                <input type="hidden" name="name" value="{{ $product->name }}">
                <button type="submit" class="btn btn-lg valBtn text-uppercase">Request Quote</button>
            </form>

Both the error and the word quote (the return view('quote'); ) are in light green so I believe that is the issue, but I cannot find what could be causing the error. I am just now learning laravel with the help of this video.

Laravel Video

Any help on this would be greatly appreciate.

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.