authorize('users.manage'); if ($user === null) { return; } $summary = $userQueries->findSummary($user); abort_if($summary === null, 404); $this->userId = $summary->id; $this->form->fillFromSummary($summary); } /** * @return list */ #[Computed] public function supervisorOptions(): array { return app(UserAccountQueries::class)->supervisorOptions($this->userId); } public function save(CreateUserAccount $createUser, UpdateUserAccount $updateUser): void { $this->authorize('users.manage'); $data = $this->form->toData(); $created = null; try { if ($this->userId === null) { $created = $createUser->execute($data); } else { $updateUser->execute($this->userId, $data); session()->flash('status', __('users.updated', ['name' => $data->name])); } } catch (UserAccountNotFound) { abort(404); } catch (DomainException $exception) { $this->form->showDomainError($exception); return; } if ($created !== null) { // Stay on the page so the admin can copy the link; it becomes // the new user's edit page. $this->userId = $created->userId; $this->setupLink = $created->setupLink->url; $this->linkStatus = __( $created->setupLink->emailSent ? 'users.created' : 'users.created_link_failed', ['name' => $data->name, 'email' => $data->email], ); $this->js('history.replaceState(history.state, "", '.json_encode(route('users.edit', $created->userId)).')'); return; } $this->redirectRoute('users.index', navigate: true); } public function sendPasswordLink(SendPasswordSetupLink $sendLink): void { $this->authorize('users.manage'); abort_if($this->userId === null, 404); try { $link = $sendLink->execute($this->userId); } catch (UserAccountNotFound) { abort(404); } $this->setupLink = $link->url; $this->linkStatus = $link->emailSent ? __('users.link_sent', ['email' => $this->form->email]) : __('users.link_mail_failed'); } public function render(): mixed { return $this->view()->title(__($this->userId === null ? 'users.create_title' : 'users.edit_title')); } }; ?>

{{ __($userId === null ? 'users.create_title' : 'users.edit_title') }}

{{-- TallStackUI's native select does not tie its label to the control, so aria-label names it. --}} @if ($form->isIntern()) @foreach ($this->supervisorOptions as $option) @endforeach @endif

{{ __('users.fields.active_description') }}

@if ($userId !== null)
@if ($linkStatus !== '')

{{ $linkStatus }}

@endif
@if ($setupLink !== '')
{{-- Without wire:model, TallStackUI ties the label to the input only through an explicit id. --}}

@endif
@endif