Coming over from Kohana to try out Laravel. I'm using the Homestead vagrant box. Following the Quickstart section, I set up a Route in the User model:
Route::get('users', function()
{
$users = User::all();
return View::make('users')->with('users', $users);
});
And entered a simple foreach loop in users.blade.php:
@extends('layout')
@section('content')
@foreach ($users as $user)
<p>{{ $user->name }}</p>
@endforeach
@stop
But loading http://homestead.app:8000/users in my browser returns an undefined variable error exception:
Undefined variable: users (View: /home/vagrant/Code/Laravel/app/views/users.blade.php)
Now, true, my users table is still empty. But that shouldn't be causing an exception. What, if anything, in my code is preventing the $users variable from being passed to the view? What have I missed?
A little progress. The query isn't returning any data, even after I've entered a few rows. Must be a db connection problem.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community