$userId, 'batch_id'=>$batchId ])->group('code')->count(); } public function batch() { return $this->belongsTo('Batch', 'batch_id', 'id', [], 'LEFT')->setEagerlyType(0); } public function course() { return $this->belongsTo('app\api\model\course\Course', 'goods_id', 'id', [], 'LEFT')->setEagerlyType(0); } }