mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-20 06:24:44 +02:00

* update ApiKeyResource * update DatabaseHostResource * update MountResource * update RoleResource * update UserResource * WebhookResource * fix phpstan * add back label translations for resources * add back other labels * upstream changes
47 lines
1.3 KiB
PHP
47 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Admin\Resources\UserResource\Pages;
|
|
|
|
use App\Filament\Admin\Resources\UserResource;
|
|
use App\Models\User;
|
|
use App\Services\Users\UserUpdateService;
|
|
use Filament\Actions\DeleteAction;
|
|
use Filament\Resources\Pages\EditRecord;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class EditUser extends EditRecord
|
|
{
|
|
protected static string $resource = UserResource::class;
|
|
|
|
private UserUpdateService $service;
|
|
|
|
public function boot(UserUpdateService $service): void
|
|
{
|
|
$this->service = $service;
|
|
}
|
|
|
|
protected function getHeaderActions(): array
|
|
{
|
|
return [
|
|
DeleteAction::make()
|
|
->label(fn (User $user) => auth()->user()->id === $user->id ? 'Can\'t Delete Yourself' : ($user->servers()->count() > 0 ? 'User Has Servers' : 'Delete'))
|
|
->disabled(fn (User $user) => auth()->user()->id === $user->id || $user->servers()->count() > 0),
|
|
$this->getSaveFormAction()->formId('form'),
|
|
];
|
|
}
|
|
|
|
protected function getFormActions(): array
|
|
{
|
|
return [];
|
|
}
|
|
|
|
protected function handleRecordUpdate(Model $record, array $data): Model
|
|
{
|
|
if (!$record instanceof User) {
|
|
return $record;
|
|
}
|
|
|
|
return $this->service->handle($record, $data);
|
|
}
|
|
}
|