// 伪代码:
class Cyline extends Model
{
public function company()
{
return $this->belongsTo('Company');
}
public function index()
{
$name[] = ['name','liek','%123%'];
$where[] = ['status','=',1];
$where[] = ['cly','=',100];
$this->hasWhere('company',$name)->with('company')->where($where)->paginate(10);
}
}
#通过hasWhere查询相对关联的compant表中符合条件的,然后再查询符合条件的当前表数据,实现了关联查询时使用多表条件同时查询
文章来源于:https://www.jianshu.com/p/9af8db0adafa