I am very new to Laravel and PHP, just trying to list all the users in my view file like this:
@foreach ($users as $user)
<li>{{ link_to("/users/{$user->username}", $user->username) }}</li>
@endforeach
But getting the error message "Invalid argument for foreach ()"
In my controller, I have the following function:
public function users() {
$user = User::all();
return View::make('users.index', ['users' => '$users']);
}
What am I doing wrong?
source
share