mirror of
https://github.com/koel/koel
synced 2024-12-21 10:03:10 +00:00
47 lines
1.2 KiB
PHP
47 lines
1.2 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace App\Console\Commands;
|
||
|
|
||
|
use App\Services\LicenseService;
|
||
|
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';
|
||
|
|
||
|
public function __construct(private LicenseService $licenseService)
|
||
|
{
|
||
|
parent::__construct();
|
||
|
}
|
||
|
|
||
|
public function handle(): int
|
||
|
{
|
||
|
$this->components->info('Activating license…');
|
||
|
|
||
|
try {
|
||
|
$license = $this->licenseService->activateLicense($this->argument('key'));
|
||
|
} catch (Throwable $e) {
|
||
|
$this->components->error($e->getMessage());
|
||
|
|
||
|
return self::FAILURE;
|
||
|
}
|
||
|
|
||
|
$this->output->success('License activated successfully. Thanks for supporting Koel!');
|
||
|
|
||
|
$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');
|
||
|
|
||
|
$this->line('');
|
||
|
|
||
|
return self::SUCCESS;
|
||
|
}
|
||
|
}
|