【发布时间】:2015-08-08 22:53:53
【问题描述】:
我有以下模型关系
型号
部门 - [id, name]
位置 - [id、sector_id、名称]
部门有很多地点
位置属于扇区
class Location extends Model {
public function sector() {
return $this->belongsTo('App\Sector');
}
}
我想使用 Laravel 5 Eloquent 进行以下查询
SELECT * FROM locations WHERE sector_id IN (1,2,3)
我试过了,
$location->where('sector_id', 'in', [1,2,3])
但是没有返回任何记录。
【问题讨论】: