Thanks the full solution I ended up with was this.
User::with('roles')->get();
Then pass that to the view with
return view('admin.users.index')->with('users', $users);
And loop through the results like so:
@foreach ($users as $user)
<tr>
<td>{!! $user->id !!}</td>
<td>{!! $user->name !!}</td>
<td>{!! $user->email !!}</td>
<td>{!! $user->created_at !!}</td>
<td>{!! $user->updated_at !!}</td>
<td>
@foreach ($user->roles as $role)
{!! $role->name !!}<br />
@endforeach
</td>
</tr>
@endforeach
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community