/**
  * Get the subscriber counts by plan.
  *
  * @return Response
  */
 public function subscribers()
 {
     $plans = [];
     foreach (Spark::allPlans() as $plan) {
         $plans[] = ['name' => $plan->name, 'interval' => $plan->interval, 'count' => $this->indicators->subscribers($plan), 'trialing' => $this->indicators->trialing($plan)];
     }
     return collect($plans)->sortByDesc('count')->values()->all();
 }
 /**
  * Execute the console command.
  *
  * @param  PerformanceIndicatorsRepository  $indicators
  * @return mixed
  */
 public function handle(PerformanceIndicatorsRepository $indicators)
 {
     DB::table('performance_indicators')->insert(['monthly_recurring_revenue' => $indicators->monthlyRecurringRevenue(), 'yearly_recurring_revenue' => $indicators->yearlyRecurringRevenue(), 'daily_volume' => DB::table('invoices')->whereDate('created_at', '=', Carbon::today())->sum('total'), 'new_users' => DB::table('users')->whereDate('created_at', '=', Carbon::today())->count(), 'created_at' => Carbon::today(), 'updated_at' => Carbon::today()]);
     $this->info('Performance indicators stored!');
 }
 /**
  * Get the user to be displayed on the user profile screen.
  *
  * @param  Request  $request
  * @param  string  $id
  * @return Response
  */
 public function show(Request $request, $id)
 {
     $user = Spark::call(UserRepository::class . '@find', [$id]);
     return response()->json(['user' => $user, 'revenue' => $this->indicators->totalRevenueForUser($user)]);
 }