Files
firefly-iii/app/Console/Commands/Upgrade/UpgradeSkeleton.php.stub
2024-12-27 09:30:41 +01:00

61 lines
1.3 KiB
Plaintext

<?php
namespace FireflyIII\Console\Commands\Upgrade;
use Illuminate\Console\Command;
class UpgradeSkeleton extends Command
{
use ShowsFriendlyMessages;
public const string CONFIG_NAME = '480_some_name';
protected $description = 'SOME DESCRIPTION';
protected $signature = 'upgrade:UPGRSKELETON {--F|force : Force the execution of this command.}';
/**
* Execute the console command.
*
* @return int
*/
public function handle(): int
{
$start = microtime(true);
if ($this->isExecuted() && true !== $this->option('force')) {
$this->friendlyInfo('This command has already been executed.');
return 0;
}
$this->friendlyWarning('Congrats, you found the skeleton command. Boo!');
//$this->markAsExecuted();
$end = round(microtime(true) - $start, 2);
$this->info(sprintf('in %s seconds.', $end));
return 0;
}
/**
* @return bool
*/
private function isExecuted(): bool
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
if (null !== $configVar) {
return (bool)$configVar->data;
}
return false;
}
/**
*
*/
private function markAsExecuted(): void
{
app('fireflyconfig')->set(self::CONFIG_NAME, true);
}
}