I'm trying to list all users and so have created a UsersController which goes like:
class UsersController extends Controller
{
public function show(User $user)
{
//
$users = User::all();
return view('superadmin.user.index', compact('users'));
}
}
And a Route that goes like:
Route::get('/superadmin/user', 'UsersController', function () {
if(Auth::user()->role[0]->id != 3) {
return redirect('/home');
} else {
return view('superadmin.user.index');
}
});
and finally trying to call it with:
@foreach ($users as $user)
{{ $user->username }}
@endforeach
But I'm getting: Parse error: syntax error, unexpected 'class' (T_CLASS), expecting ',' or ';'
On the class UsersController line, so i at least know its getting that far. Ive read all the parse error questions and followed a few tutorials on listing users but everything seems to hang up here.
Where am I going wrong?