File: /var/www/quadcode/app/Console/Commands/BitrixStatusesSync.php
<?php
namespace App\Console\Commands;
use App\Services\BitrixService;
use Illuminate\Console\Command;
use Symfony\Component\Console\Command\Command as CommandAlias;
class BitrixStatusesSync extends Command
{
protected $signature = 'bitrix:statuses-sync';
protected $description = 'Sync Bitrix statuses';
public function handle(BitrixService $bitrixService): int
{
$this->info($this->description);
if (!$bitrixService->check()) {
$this->error('Need to fill BITRIX24_HOST, BITRIX24_USER_ID or BITRIX24_TOKEN in .env');
return CommandAlias::FAILURE;
}
if (!$bitrixService->syncStatuses()) {
$this->error($bitrixService->lastError);
return CommandAlias::FAILURE;
}
foreach ($bitrixService->getLastActionLog() as $log) {
$this->line($log);
}
$this->info('Done');
return CommandAlias::SUCCESS;
}
}