From 6bc77e7e91f9c604a298c12a6b4895fa774be702 Mon Sep 17 00:00:00 2001 From: denghy Date: Fri, 10 May 2019 17:51:52 +0800 Subject: [PATCH] count --- app/Domains/Virtual/Services/CardService.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Domains/Virtual/Services/CardService.php b/app/Domains/Virtual/Services/CardService.php index 0f77bebc..7bd76896 100644 --- a/app/Domains/Virtual/Services/CardService.php +++ b/app/Domains/Virtual/Services/CardService.php @@ -52,16 +52,16 @@ class CardService extends Service if (isset($conditions['card_status'])) { $conditions['type'] = [0, 1, 2]; + $total = $this->orderCardPartitionRepository->withConditions($conditions)->count(); $simArray = $this->orderCardPartitionRepository->selectRaw('sim')->withConditions($conditions)->orderBy('sim')->forPage($page, $limit)->get()->pluck('sim')->toArray(); - $cards = $this->orderCardPartitionRepository->select($select)->whereIn('sim', $simArray)->get(); + $cards = $this->orderCardPartitionRepository->select($select)->where('type', 0)->whereIn('sim', $simArray)->get(); } else { + $total = $this->orderCardPartitionRepository->withConditions($conditions)->count(); $cards = $this->orderCardPartitionRepository->select($select)->withConditions($conditions)->orderBy('created_at', 'desc')->forPage($page, $limit)->get(); } $cards = static::transformer($cards); - $total = $this->orderCardPartitionRepository->withConditions($conditions)->count(); - return new LengthAwarePaginator($cards, $total, $limit); }