Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

syntax error, unexpected token ";", expecting ")"

I’m trying to display a list of users in a table and provide a link for each user to view their details on a separate page. However, I get a parse error

Here are my codes

User list page:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

<table class="user-list-table table">
        <thead class="table-light">
          <tr>
            <th></th>
            <th>Name</th>
            <th>Email</th>
            <th>Password</th>
            <th>Phone Number</th>
            <th>Admin</th>
          </tr>
        </thead>
        <tbody>
          @foreach($users as $item)
          <tr>
            <td>{{ $loop->iteration }}</td>
            <td>
              <a 
              href="{{ route('user-view', ['id' => $item->id] }}">
              {{ $item->name }}
            </a>
            </td>
            <td>{{ $item->email }}</td>
            <td>{{ $item->password }}</td>
            <td>{{ $item->phone_number }}</td>
            <td>{{ $item->is_admin }}</td>

          </tr>
          @endforeach
        </tbody>
      </table>

The UserController:

public function show($id)
    {
        $user = User::find($id);
        return view('main.user.user-view-account')->with('user', $user);
    }

The route to main.user.user-view-account:

Route::get('user-view/{id}', [UserController::class, 'show'])->name('user-view');

I’m trying to route user to user/id/view, can anybody see what is causing the error please

>Solution :

inside your Anchor tag you need to close your route

<a 
  href="{{ route('user-view', ['id' => $item->id]) }}"
>
  {{ $item->name }}
</a>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading