userRepo = $userRepo; $this->userSvc = $userService; } /** * Recalculate the stats for active users * * @param CronNightly $event * * @throws \UnexpectedValueException * @throws \InvalidArgumentException */ public function handle(CronNightly $event): void { Log::info('Recalculating balances'); $w = [ ['state', '!=', UserState::REJECTED], ]; $users = $this->userRepo->findWhere($w, ['id', 'name', 'airline_id']); foreach ($users as $user) { $this->userSvc->recalculateStats($user); } Log::info('Done recalculating stats'); } }