Call to undefined method Illuminate\Database\Eloquent\Collection::with()

eloquent, laravel, laravel-4

Solution

The function `all()` executes the query so you get a collection. You have to call `with` on a query builder instance. Meaning you should do this:

foo::with('foos', 'bars')->get();

Also, classes start with a capital letter by convention so it should be `Foo` ;)

Problem

my route code ``` return View::make('test')->with('foo', foo::all()->with('foos', 'bars')); ``` why this is throwing this exception?

Original source