Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

eager load relationships on an existing model in route laravel

Route::get('categories/{category:slug}', function(Category $category) {
    return view('posts', [
        'posts' => $category->posts->load(['category', 'author'])
    ]);
});
Source by laracasts.com #
 
PREVIOUS NEXT
Tagged: #eager #load #relationships #existing #model #route #laravel
ADD COMMENT
Topic
Name
2+8 =