first commit
This commit is contained in:
45
laravel/app/Console/Commands/SyncIncomesCommand.php
Normal file
45
laravel/app/Console/Commands/SyncIncomesCommand.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Contracts\WbSyncManagerInterface;
|
||||
use App\Enums\WbEndpoint;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
final class SyncIncomesCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'sync:incomes {--dateFrom=} {--dateTo=}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Sync incomes from WB API';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(WbSyncManagerInterface $manager): int
|
||||
{
|
||||
$dateFrom = $this->option('dateFrom');
|
||||
$dateTo = $this->option('dateTo');
|
||||
|
||||
$dateFrom = $dateFrom ?: Carbon::now()->subYear()->toDateString();
|
||||
$dateTo = $dateTo ?: Carbon::yesterday()->toDateString();
|
||||
|
||||
$manager->start(WbEndpoint::INCOMES, $dateFrom, $dateTo);
|
||||
|
||||
$this->info('Sync started');
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user