📜  laravel 中的急切关系 - PHP 代码示例

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

代码示例1
$parentLineCategories = ProductCategory::with([
            'children' => function ($child) use ($SpecificID) {
                return $child->with([
                    'products' => function ($product) use ($SpecificID) {
                        return $product->with([
                            'types' => function ($type) use ($SpecificID) {
                                return $type->where('id', $SpecificID);
                            }
                        ]);
                    }
                ]);
            }
        ])->get();