lasthourcloud/app/Livewire/CheckLicense.php

45 lines
1.3 KiB
PHP
Raw Normal View History

2023-07-14 09:27:08 +00:00
<?php
2023-12-07 18:06:32 +00:00
namespace App\Livewire;
2023-07-14 09:27:08 +00:00
use App\Actions\License\CheckResaleLicense;
use App\Models\InstanceSettings;
use Livewire\Component;
class CheckLicense extends Component
{
public InstanceSettings|null $settings = null;
public string|null $instance_id = null;
protected $rules = [
'settings.resale_license' => 'nullable',
'settings.is_resale_license_active' => 'nullable',
];
protected $validationAttributes = [
'settings.resale_license' => 'License',
'instance_id' => 'Instance Id (Do not change this)',
'settings.is_resale_license_active' => 'Is License Active',
];
2023-07-14 09:27:08 +00:00
public function mount()
{
$this->instance_id = config('app.id');
$this->settings = InstanceSettings::get();
}
2023-07-14 09:27:08 +00:00
public function submit()
{
$this->validate();
$this->settings->save();
if ($this->settings->resale_license) {
try {
CheckResaleLicense::run();
2023-12-07 18:06:32 +00:00
$this->dispatch('reloadWindow');
2023-09-11 15:36:30 +00:00
} catch (\Throwable $e) {
session()->flash('error', 'Something went wrong. Please contact support. <br>Error: ' . $e->getMessage());
ray($e->getMessage());
2023-12-07 21:56:55 +00:00
return $this->redirect('/settings/license', navigate: true);
2023-07-14 09:27:08 +00:00
}
}
}
}