📜  路由 laravel 中现有模型的急切负载关系 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:23.135000             🧑  作者: Mango

代码示例1
Route::get('categories/{category:slug}', function(Category $category) {
    return view('posts', [
        'posts' => $category->posts->load(['category', 'author'])
    ]);
});