AutoGrantRewards.php 616 B

12345678910111213141516171819
  1. <?php
  2. namespace App\Console\Commands;
  3. use App\Services\AutomaticRewardGrantService;
  4. use Illuminate\Console\Command;
  5. class AutoGrantRewards extends Command
  6. {
  7. protected $signature = 'rewards:auto-grant';
  8. protected $description = 'Grant eligible rebate/backflow rewards only when their automatic schedule is enabled and due';
  9. public function handle(AutomaticRewardGrantService $service): int
  10. {
  11. $result = $service->run();
  12. $this->line(json_encode($result, JSON_UNESCAPED_UNICODE));
  13. return array_sum(array_column($result, 'failed')) > 0 ? self::FAILURE : self::SUCCESS;
  14. }
  15. }