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 App\Values\LicenseStatus;
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
use Throwable;
|
|
|
|
|
|
|
|
class CheckLicenseStatusCommand extends Command
|
|
|
|
{
|
|
|
|
protected $signature = 'koel:license:status';
|
2024-03-09 12:20:36 +00:00
|
|
|
protected $description = 'Check the current Koel Plus license status';
|
2024-01-05 16:42:50 +00:00
|
|
|
|
2024-01-09 18:34:40 +00:00
|
|
|
public function __construct(private LicenseServiceInterface $licenseService)
|
2024-01-05 16:42:50 +00:00
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function handle(): int
|
|
|
|
{
|
|
|
|
$this->components->info('Checking your Koel Plus license status…');
|
|
|
|
|
|
|
|
try {
|
2024-01-08 13:02:26 +00:00
|
|
|
$status = $this->licenseService->getStatus(checkCache: false);
|
2024-01-05 16:42:50 +00:00
|
|
|
|
|
|
|
switch ($status->status) {
|
|
|
|
case LicenseStatus::STATUS_VALID:
|
2024-01-08 13:02:26 +00:00
|
|
|
$this->output->success('You have a valid Koel Plus license. All Plus features are enabled.');
|
2024-01-05 16:42:50 +00:00
|
|
|
$this->components->twoColumnDetail('License Key', $status->license->short_key);
|
|
|
|
|
|
|
|
$this->components->twoColumnDetail(
|
|
|
|
'Registered To',
|
|
|
|
"{$status->license->meta->customerName} <{$status->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
|
|
|
break;
|
|
|
|
|
|
|
|
case LicenseStatus::STATUS_NO_LICENSE:
|
|
|
|
$this->components->info(
|
2024-03-22 14:02:07 +00:00
|
|
|
'No license found. You can purchase one at https://store.koel.dev/checkout/buy/'
|
|
|
|
. config('lemonsqueezy.plus_product_id')
|
2024-01-05 16:42:50 +00:00
|
|
|
);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LicenseStatus::STATUS_INVALID:
|
2024-01-08 13:02:26 +00:00
|
|
|
$this->components->error('Your license is invalid. Plus features will not be available.');
|
2024-01-05 16:42:50 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
$this->components->warn('Your license status is unknown. Please try again later.');
|
|
|
|
}
|
|
|
|
} catch (Throwable $e) {
|
|
|
|
$this->output->error($e->getMessage());
|
|
|
|
}
|
|
|
|
|
|
|
|
return self::SUCCESS;
|
|
|
|
}
|
|
|
|
}
|