Created
September 24, 2018 01:55
-
-
Save didikz/80708331d6b582fb14094d726d3c73cf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| class SomeClass { | |
| public function dashboard(Request $request) | |
| { | |
| $user = $this->userSummary(); | |
| $merchant = $this->merchantSummary(); | |
| return response()->json([...]); | |
| } | |
| private function userSummary() | |
| { | |
| $user['total'] = User::where('type', 'customer')->count(); | |
| $user['today'] = User::where('type', 'customer')->whereDate('created_at', date('Y-m-d'))->count(); | |
| $user['active'] = User::where('type', 'customer')->where('is_active', true)->count(); | |
| $user['suspended'] = User::where('type', 'customer')->where('is_active', false)->count(); | |
| return $user; | |
| } | |
| private function merchantSummary() | |
| { | |
| $merchant['total'] = Merchant::published()->count(); | |
| $merchant['today'] = Merchant::published()->whereDate('created_at', date('Y-m-d'))->count(); | |
| $merchant['active'] = Merchant::published()->where('is_active', true)->count(); | |
| $merchant['suspended'] = Merchant::published()->where('is_active', false)->count(); | |
| return $merchant; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment