38 lines
958 B
PHP
38 lines
958 B
PHP
<?php
|
|
|
|
namespace App\Livewire\Addons;
|
|
|
|
use App\Services\AddonRegistry;
|
|
use App\Services\AddonService;
|
|
use Livewire\Attributes\Layout;
|
|
use Livewire\Attributes\On;
|
|
use Livewire\Component;
|
|
|
|
#[Layout('layouts.app')]
|
|
class Index extends Component
|
|
{
|
|
/** Key awaiting an uninstall confirmation — set by the card before the confirm modal opens. */
|
|
public ?string $pendingUninstall = null;
|
|
|
|
public function install(string $key): void
|
|
{
|
|
app(AddonService::class)->install($key);
|
|
}
|
|
|
|
#[On('addon-uninstall')]
|
|
public function uninstall(): void
|
|
{
|
|
if ($this->pendingUninstall !== null && AddonRegistry::has($this->pendingUninstall)) {
|
|
app(AddonService::class)->uninstall($this->pendingUninstall);
|
|
$this->pendingUninstall = null;
|
|
}
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
return view('livewire.addons.index', [
|
|
'addons' => AddonRegistry::withState(),
|
|
]);
|
|
}
|
|
}
|