2024-01-08 13:02:26 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
|
2024-02-23 18:36:02 +00:00
|
|
|
use App\Services\License\Contracts\LicenseServiceInterface;
|
2024-01-08 13:02:26 +00:00
|
|
|
use Illuminate\Console\Command;
|
|
|
|
use Throwable;
|
|
|
|
|
|
|
|
class DeactivateLicenseCommand extends Command
|
|
|
|
{
|
|
|
|
protected $signature = 'koel:license:deactivate';
|
|
|
|
protected $description = 'Deactivate the currently active Koel Plus license';
|
|
|
|
|
2024-04-18 14:36:28 +00:00
|
|
|
public function __construct(private readonly LicenseServiceInterface $licenseService)
|
2024-01-08 13:02:26 +00:00
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function handle(): int
|
|
|
|
{
|
2024-04-18 14:36:28 +00:00
|
|
|
$status = $this->licenseService->getStatus();
|
2024-01-08 13:02:26 +00:00
|
|
|
|
|
|
|
if ($status->hasNoLicense()) {
|
|
|
|
$this->components->warn('No active Plus license found.');
|
|
|
|
|
|
|
|
return self::SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$this->confirm('Are you sure you want to deactivate your Koel Plus license?')) {
|
|
|
|
$this->output->warning('License deactivation aborted.');
|
|
|
|
|
|
|
|
return self::SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->components->info('Deactivating your license…');
|
|
|
|
|
|
|
|
try {
|
2024-04-18 14:36:28 +00:00
|
|
|
$this->licenseService->deactivate($status->license);
|
2024-01-08 13:02:26 +00:00
|
|
|
$this->components->info('Koel Plus has been deactivated. Plus features are now disabled.');
|
|
|
|
|
|
|
|
return self::SUCCESS;
|
|
|
|
} catch (Throwable $e) {
|
|
|
|
$this->components->error('Failed to deactivate Koel Plus: ' . $e->getMessage());
|
|
|
|
|
|
|
|
return self::FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|