2024-01-05 16:42:50 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
|
2024-02-23 18:36:02 +00:00
|
|
|
use App\Services\License\Contracts\LicenseServiceInterface;
|
2024-01-05 16:42:50 +00:00
|
|
|
use Illuminate\Console\Command;
|
|
|
|
use Throwable;
|
|
|
|
|
|
|
|
class ActivateLicenseCommand extends Command
|
|
|
|
{
|
|
|
|
protected $signature = 'koel:license:activate {key : The license key to activate.}';
|
|
|
|
protected $description = 'Activate a Koel Plus license';
|
|
|
|
|
2024-04-18 14:36:28 +00:00
|
|
|
public function __construct(private readonly LicenseServiceInterface $licenseService)
|
2024-01-05 16:42:50 +00:00
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function handle(): int
|
|
|
|
{
|
|
|
|
$this->components->info('Activating license…');
|
|
|
|
|
|
|
|
try {
|
2024-01-08 13:02:26 +00:00
|
|
|
$license = $this->licenseService->activate($this->argument('key'));
|
2024-01-05 16:42:50 +00:00
|
|
|
} catch (Throwable $e) {
|
|
|
|
$this->components->error($e->getMessage());
|
|
|
|
|
|
|
|
return self::FAILURE;
|
|
|
|
}
|
|
|
|
|
2024-01-08 13:02:26 +00:00
|
|
|
$this->output->success('Koel Plus activated! All Plus features are now available.');
|
2024-01-05 16:42:50 +00:00
|
|
|
$this->components->twoColumnDetail('License Key', $license->short_key);
|
|
|
|
|
|
|
|
$this->components->twoColumnDetail(
|
|
|
|
'Registered To',
|
|
|
|
"{$license->meta->customerName} <{$license->meta->customerEmail}>"
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->components->twoColumnDetail('Expires On', 'Never ever');
|
2024-01-07 12:43:10 +00:00
|
|
|
$this->newLine();
|
2024-01-05 16:42:50 +00:00
|
|
|
|
|
|
|
return self::SUCCESS;
|
|
|
|
}
|
|
|
|
}
|