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:
<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>