📜  laravel 子关系按 desc 排序 - PHP 代码示例

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

代码示例1
// order one relation with a specific order 
Model::with(['relation1'])
        ->with(['relation2' => function($query)  {
            $query->orderBy('relation2_column_name','DESC');
           }
        ])
         ->where('slug', $slug)->first();