Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

nmtechnology's avatar

syntax error, unexpected 'user' (T_STRING), expecting ')'

This is what the line looks like below. Stack trace is highlighting a syntax error here in this line. It seems like it has an issue with all my route syntax. I have commented out this line and then stack trace just pulls up my next route as an issue and so on. I don't know what happened because this syntax was never an issue before. I am at Laravel version 7.11 and recently upgraded this project to that version.

<li><a href="{{ route('user.orders') }}"> Active Companions</a></li>

0 likes
12 replies
ousid's avatar

Can you provide the whole code in the file and give us the version of PHP you are working with.

Cause this code it seems Correct

	<li>
		<a href="{{ route('user.orders') }}">
			Active Campanions
		</a>
	</li>
1 like
nmtechnology's avatar

I am using PHP 7.4.5

Should I post the user orders controller code?

nmtechnology's avatar

WEB.PHP file

<?php

use Illuminate\Support\Facades\Route;
use App\Events\OrderStatusChanged;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
	return view('welcome');
});

Route::get('/fire', function () {
	event(new OrderStatusChanged);

	return 'Fired';
});

Auth::routes();

// User Routes
Route::middleware('auth')->group(function () {
	Route::get('/orders', 'UserOrdersController@index')->name('user.orders');
	Route::get('/orders/create', 'UserOrdersController@create')->name('user.orders.create');
	Route::post('/orders', 'UserOrdersController@store')->name('user.orders.store');
	Route::get('/orders/{order}', 'UserOrdersController@show')->name('user.orders.show');
});

//Route::get('/qr-code', 'QRController@make');


// Admin Routes - Make sure you implement an auth layer here
Route::prefix('admin')->group(function () {
	Route::get('/orders', 'AdminOrdersController@index')->name('admin.orders');
	Route::get('/orders/edit/{order}', 'AdminOrdersController@edit')->name('admin.orders.edit');
	Route::patch('/orders/{order}', 'AdminOrdersController@update')->name('admin.orders.update');
});

Route::redirect('/admin', '/admin/orders');
nmtechnology's avatar

APP.BLADE.PHP file

<!DOCTYPE html>
<html lang="{{ app()->getLocale() }}">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- CSRF Token -->
    <meta name="csrf-token" content="{{ csrf_token() }}">

    <title>{{ config('app.name', 'CompanionCloud') }}</title>

    <!-- Styles -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/css/bulma.min.css">
    <script defer src="https://use.fontawesome.com/releases/v5.3.1/js/all.js"></script>
    <link href="{{ asset('css/app.css) }}" rel="stylesheet">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
    <div id="app">
        <nav class="navbar navbar-default navbar-static-top">
            <div class="container">
                <div class="navbar-header">

                    <!-- Collapsed Hamburger -->
                    <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#app-navbar-collapse">
                        <span class="sr-only">Toggle Navigation</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>

                    <!-- Branding Image -->
                    <a class="navbar-brand">
                        CompanionCloud
                    </a>
                </div>

                <div class="collapse navbar-collapse" id="app-navbar-collapse">
                    <!-- Left Side Of Navbar -->
                    <ul class="nav navbar-nav">
                        @auth
                            <li><a href="{{ route('user.orders') }}"> Active Companions</a></li>

                            {{-- Admin Routes --}}
                            <li><a href="{{ route('admin.orders') }}"> Messaging Center</a></li>
                        @endauth
                    </ul>

                    <!-- Right Side Of Navbar -->
                    <ul class="nav navbar-nav navbar-right">
                        <!-- Authentication Links -->
                        @guest
                            <li><a href="{{ route('login') }}">Login</a></li>
                            <li><a href="{{ route('register') }}">Register</a></li>
                        @else

                            @include('partials.notifications-dropdown')

                            <li class="dropdown">
                                <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
                                    {{ Auth::user()->name }} <span class="caret"></span>
                                </a>

                                <ul class="dropdown-menu" role="menu">
                                    <li>
                                        <a href="{{ route('logout') }}"
                                            onclick="event.preventDefault();
                                                     document.getElementById('logout-form').submit();">
                                            Logout
                                        </a>

                                        <form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
                                            {{ csrf_field() }}
                                        </form>
                                    </li>
                                </ul>
                            </li>
                        @endguest
                    </ul>
                </div>
            </div>
        </nav>

        @yield('content')
    </div>

    <script src="{{ asset('js/app.js') }}"></script>

    @yield('extra-js')
</body>
</html>
nmtechnology's avatar

And here is my SHOW.BLADE.PHP view

@extends('layouts.app')

@section('content')
<div class="container-fluid">
    <div class="row">
        <br>
        <br>
        <br>
        <div class="col-md-8">
            <div class="panel panel-default">
                <div class="panel-heading">Active Companion Panel
                <a href="{{ route('user.orders.create') }}"> <button class="button is-primary is-large is-link is-rounded col-lg-offset-9">Add Companion</button></a>



                <div class="panel-body container-fluid">
                    @if (session('message'))
                        <div class="alert alert-success">
                            {{ session('message') }}
                        </div>
                    @endif

                @if ($orders->count() == 0)
                    <p>No orders yet.</p>


                @else

                    <order-alert user_id="{{ auth()->user()->id }}"></order-alert>


                    <div class="table-responsive">
                        <table class="table table-striped table-bordered">
                            <thead>
                                <tr>
                                    <th>Status</th>
                                    <th>ID</th>
                                    <th>Address</th>
                                    <th>Size</th>
                                    <th>Toppings</th>
                                    <th>Instructions</th>
                                </tr>
                            </thead>
                            <tbody>
                                @foreach ($orders as $order)
                                    <tr>
                                        <td><order-progress status="{{ $order->status->name}}"
                                                            initial=" {{ $order->status->percent }}"
                                                            order_id="{{ $order->id }}"></order-progress></td>
                                        <td><a href="{{ route('user.orders.show', $order) }}">APMS{{ $order->id }}</td>
                                        <td>{{ $order->address }}</td>
                                        <td>{{ $order->size }}</td>
                                        <td>{{ $order->toppings }}</td>
                                        <td>{{ $order->instructions }}</td>
                                    </tr>
                                @endforeach
                            </tbody>

                        </table>
                    </div> <!-- end table-responsive -->

                @endif

                </div>
            </div>
        </div>
    </div>
</div>
@endsection
nmtechnology's avatar

Yea this syntax was working previously, obviously, but now I am not sure at what point after I finished building a form this started acting up. Once I was going to try and see if the submit button worked for my form this issue appeared and none of my views work except for my welcome/landing page. I am trying to back track my terminal cmd's and trying to retrace my steps through the form build. Can't think of anything substantial I may have done beside the upgrade to cause this.

I posted my route and view files so I appreciate any help thank you!

I upgraded to Laravel 7.11 and all my views were working fine after the upgrade so I don't think it's something that had to do with the upgrade.

MichalOravec's avatar

I checked it and it seems to be everything ok.

Just try

php artisan view:clear
nmtechnology's avatar

Thank you MichalORAVEC but I tried php artisan view:clear and the issue still persists. Thanks for the idea though, I am going to try and roll back to a previous git push and see if I can avoid recreating the problem. I think that's my only option right now.

Do you think helpers have anything to do with these views not loading?

Please or to participate in this conversation.