mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-20 16:54:45 +02:00
60 lines
1.2 KiB
PHP
60 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Server\Pages;
|
|
|
|
use App\Models\Server;
|
|
use Filament\Facades\Filament;
|
|
use Filament\Forms\Concerns\InteractsWithForms;
|
|
use Filament\Schemas\Components\Form;
|
|
use Filament\Pages\Concerns\InteractsWithFormActions;
|
|
use Filament\Pages\Page;
|
|
|
|
/**
|
|
* @property Form $form
|
|
*/
|
|
abstract class ServerFormPage extends Page
|
|
{
|
|
use InteractsWithFormActions;
|
|
use InteractsWithForms;
|
|
|
|
protected string $view = 'filament.server.pages.server-form-page';
|
|
|
|
public ?array $data = [];
|
|
|
|
public function mount(): void
|
|
{
|
|
$this->authorizeAccess();
|
|
|
|
$this->fillForm();
|
|
}
|
|
|
|
protected function authorizeAccess(): void {}
|
|
|
|
protected function fillform(): void
|
|
{
|
|
$data = $this->getRecord()->attributesToArray();
|
|
$this->form->fill($data);
|
|
}
|
|
|
|
public function getRecord(): Server
|
|
{
|
|
/** @var Server $server */
|
|
$server = Filament::getTenant();
|
|
|
|
return $server;
|
|
}
|
|
|
|
// TODO: find better way handle server conflict state
|
|
public static function canAccess(): bool
|
|
{
|
|
/** @var Server $server */
|
|
$server = Filament::getTenant();
|
|
|
|
if ($server->isInConflictState()) {
|
|
return false;
|
|
}
|
|
|
|
return parent::canAccess();
|
|
}
|
|
}
|