From 1351b340a8bfb7236634ca0a3e380aa56451b2ca Mon Sep 17 00:00:00 2001 From: denghy Date: Fri, 10 May 2019 18:14:52 +0800 Subject: [PATCH] first --- app/Domains/Virtual/Services/CardService.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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();