SyncShareFacts.php 850 B

12345678910111213141516171819
  1. <?php
  2. namespace App\Console\Commands;
  3. use App\Services\Sharing\BetFactSynchronizer;
  4. use Illuminate\Console\Command;
  5. class SyncShareFacts extends Command
  6. {
  7. protected $signature = 'share:sync-facts {--from= : UTC+8 original betting date Y-m-d} {--to= : UTC+8 original betting date Y-m-d} {--write : Persist facts; default is read-only preview}';
  8. protected $description = 'Preview or synchronize current real betting facts for the sharing system';
  9. public function handle(BetFactSynchronizer $synchronizer): int
  10. {
  11. $result = $synchronizer->sync($this->option('from') ?: null, $this->option('to') ?: null, (bool) $this->option('write'));
  12. $this->line(json_encode($result, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR));
  13. return $result['errors'] === [] ? self::SUCCESS : self::FAILURE;
  14. }
  15. }