public function items() { return $this->belongsToMany('App\Model\Cz\CzCourse', 'cz_picture_course', 'picture_id', 'course_id'); } //获取分类 public function getList() { $list=$this->with(['items'=>function($query){ $query->where('status',"1"); }])->where('status',1)->select('picture_id',"picture_type_name")->orderBy('sort', 'ASC')->get()->toArray(); foreach ($list as $k=>$item) { if (empty($item['items'])){ unset($list[$k]); } } return $list; }
laravel 多表字段关联查询
猜你喜欢
转载自www.cnblogs.com/phpwyl/p/10716090.html
今日推荐
周排行