【发布时间】:2016-06-08 13:54:17
【问题描述】:
我的一个模型包含以下内容:
public function from()
{
return $this->belongsTo(Station::class, 'from_station_id');
}
public function to()
{
return $this->belongsTo(Station::class, 'to_station_id');
}
为了使用它,我使用了with('to', 'from') 方法。结果如下:
select * from "stations" where "stations"."id" in ('1')
select * from "stations" where "stations"."id" in ('2')
两个缓存查询,一个用于“to's”,一个用于“from's”。目前有 1 条记录,它们是“有用的”。但是以后他们会有很多重复的ID..
Laravel 是否提供组合这些选项的选项?
【问题讨论】:
标签: laravel