laravel orm

如何使用 Repository 模式

https://learnku.com/articles/39000

因为关联关系有用到 id 字段,肯定就需要查询出来,不然 ORM 无法关联整理成对应的数据结构。不过有更好的方法,不要约束在这个里面,如:

$result = Brand::with(['brand' =>  function($query){
    $query->select('id', 'briefCode');
}])->get();
原文地址:https://www.cnblogs.com/agang-php/p/14933910.html