Skip to content

Instantly share code, notes, and snippets.

@didikz
Created September 24, 2018 01:55
Show Gist options
  • Select an option

  • Save didikz/80708331d6b582fb14094d726d3c73cf to your computer and use it in GitHub Desktop.

Select an option

Save didikz/80708331d6b582fb14094d726d3c73cf to your computer and use it in GitHub Desktop.
<?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