mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-20 01:44:45 +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
51 lines
1.1 KiB
PHP
51 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Admin\Resources\UserResource\Pages;
|
|
|
|
use App\Filament\Admin\Resources\UserResource;
|
|
use App\Models\Role;
|
|
use App\Services\Users\UserCreationService;
|
|
use Filament\Resources\Pages\CreateRecord;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class CreateUser extends CreateRecord
|
|
{
|
|
protected static string $resource = UserResource::class;
|
|
|
|
protected static bool $canCreateAnother = false;
|
|
|
|
private UserCreationService $service;
|
|
|
|
public function boot(UserCreationService $service): void
|
|
{
|
|
$this->service = $service;
|
|
}
|
|
|
|
protected function getHeaderActions(): array
|
|
{
|
|
return [
|
|
$this->getCreateFormAction()->formId('form'),
|
|
];
|
|
}
|
|
|
|
protected function getFormActions(): array
|
|
{
|
|
return [];
|
|
}
|
|
|
|
protected function handleRecordCreation(array $data): Model
|
|
{
|
|
$data['root_admin'] = false;
|
|
|
|
$roles = $data['roles'];
|
|
$roles = collect($roles)->map(fn ($role) => Role::findById($role));
|
|
unset($data['roles']);
|
|
|
|
$user = $this->service->handle($data);
|
|
|
|
$user->syncRoles($roles);
|
|
|
|
return $user;
|
|
}
|
|
}
|