tp5.1 模型关联时 使用多个表的条件去查询数据集

2020-07-02
// 伪代码:
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

{/if}