i am following this tutorial http://scotch.io/tutorials/php/a-guide-to-using-eloquent-orm-in-laravel#sample-application
On this tutorial below code is use for routing a page with bread model & all the model related to it
// Route::get('eloquent', function() {
return View::make('eloquent')
// all the bears (will also return the fish, trees, and picnics that belong to them)
->with('bears', Bear::all()->with('trees', 'picnics'));
});
but when i run this below error appear
Symfony\Component\Debug\Exception\FatalErrorException thrown with message "Call to undefined method Illuminate\Database\Eloquent\Collection::with()"
Stacktrace: #1 Symfony\Component\Debug\Exception\FatalErrorException in J:\server2\htdocs\practice\laravel\app\routes.php:18 #0 Illuminate\Exception\Handler:handleShutdown in <#unknown>:0
Now what should i do ???
The "all" function returns a collection, not a query. You need to use something like Bears::with('trees', 'picnics')->get()
.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community