diff --git a/app/Domains/Virtual/Services/CardService.php b/app/Domains/Virtual/Services/CardService.php index 358b197a..2f47ff66 100644 --- a/app/Domains/Virtual/Services/CardService.php +++ b/app/Domains/Virtual/Services/CardService.php @@ -57,12 +57,13 @@ class CardService extends Service $simArray = $this->orderCardPartitionRepository->selectRaw('sim')->withConditions($conditions)->orderBy('sim')->forPage($page, $limit)->get()->pluck('sim')->toArray(); $subQuery = $this->orderCardPartitionRepository->selectRaw('sim')->withConditions($conditions)->currentModel(); - $query = DB::table(DB::raw("({$subQuery->toSql()}) as sub")) - ->select(DB::raw('count(sim)')) + $res = DB::table(DB::raw("({$subQuery->toSql()}) as sub")) + ->select(DB::raw('count(*) as total')) ->mergeBindings($subQuery->getQuery()) - ->get(); + ->first(); + + $total = $res->total; - $total = $query->count; $cards = $this->orderCardPartitionRepository->select($select)->where('type', 0)->whereIn('sim', $simArray)->get(); } else { $total = $this->orderCardPartitionRepository->withConditions($conditions)->count();