File: /var/www/ipsremont-demo/app/Console/Commands/AbstractImport.php
<?php
namespace App\Console\Commands;
use App\Models\Region;
use App\Traits\Base1c;
use Illuminate\Console\Command;
use Illuminate\Database\Eloquent\Collection;
abstract class AbstractImport extends Command
{
use Base1c;
protected ?Region $region = null;
protected bool $isDebug = false;
protected bool $isForce = false;
protected string $title = '';
abstract public function executeCommand(Region $region);
public function handle(): void
{
$this->isDebug = (bool) $this->option('debug');
$this->isVerbose = (bool) $this->option('echo');
$this->isForce = (bool) $this->option('force');
$this->info($this->title . ' ' . date('Y-m-d H:i:s') . PHP_EOL);
/** @var Collection|Region[] $regions */
$regions = Region::all();
foreach ($regions as $region) {
// TODO Для тестов пока только так
if ('Казахстан' !== $region->name) {
continue;
}
$this->region = $region;
$this->info('Регион: ' . $region->name);
$this->executeCommand($region);
}
}
}