也许需求: 1.需要获取订单和订单的商品详情 2.表 order 、 goods 、 barcode
现在: order hasMany goods 、 goods hasOne barcode
怎么写链式?
Order::with('goods')->get();
Order 模型里: function goods() { return $this->hasMany(Goods::class, 'id', 'id'); }
Goods 模型里: function barcode() { return $this->hasOne(Barcode::class, 'id', 'id'); }
现在懵逼了,不会用。。
1
ylsc633 2017 年 1 月 10 日
github 随便找个博客,看下他们的 分类 帖子 评论
或者 权限 角色 用户 关系.. |
2
phpcxy 2017 年 1 月 10 日
```
Order::with('goods.barcode')->get(); ``` |
3
holyghost 2017 年 1 月 10 日
|