authorize('jobs.manage'); if ($job === null) { $this->form->responsible_user_id = (string) auth()->id(); return; } $details = $jobQueries->findDetails($job); abort_if($details === null, 404); $this->jobId = $details->id; $this->jobNumber = $details->number; $this->customerName = $details->customer->name; $this->storedStatus = $details->status->value; $this->form->fillFromDetails($details); } public function save(CreateCustomerJob $createJob, UpdateCustomerJob $updateJob, CustomerJobQueries $jobQueries): void { $this->authorize('jobs.manage'); $status = JobStatus::tryFrom($this->form->status); if ($status !== null && $status->value !== $this->storedStatus && ! $this->maySetStatus($status)) { $this->addError('form.status', __('jobs.errors.status_not_allowed')); return; } $data = $this->form->toData(); try { if ($this->jobId === null) { $jobId = $createJob->execute($data, (int) auth()->id()); $number = $jobQueries->findDetails($jobId)->number ?? ''; session()->flash('status', __('jobs.created', ['number' => $number, 'name' => trim($data->name)])); } else { $updateJob->execute($this->jobId, $data, (int) auth()->id()); $jobId = $this->jobId; session()->flash('status', __('jobs.updated', ['number' => $this->jobNumber])); } } catch (CustomerJobNotFound) { abort(404); } catch (DomainException $exception) { $this->form->showDomainError($exception); return; } $this->redirectRoute('jobs.show', $jobId, navigate: true); } public function heading(): string { return $this->jobId === null ? __('jobs.create_title') : __('jobs.edit_title').' '.$this->jobNumber; } public function render(): mixed { return $this->view()->title($this->heading()); } }; ?> @php $userOptions = collect($this->users)->map(fn ($user) => [ 'value' => $user->id, 'label' => $user->name, 'note' => $user->role === Role::Subcontractor ? __('users.roles.subcontractor') : null, ])->all(); $staffOptions = collect($this->users)->reject(fn ($user) => $user->role === Role::Subcontractor); @endphp
{{ $this->heading() }}

{{ $statusMessage }}

{{ __('jobs.sections.basics') }}
{{ __('jobs.sections.schedule') }}
{{ __('jobs.sections.classification') }}
{{-- TallStackUI's native select does not tie its label to the control, so aria-label names it. --}} @foreach ($this->statusOptions as $status) @endforeach @foreach (Priority::cases() as $priority) @endforeach @foreach (JobKind::cases() as $kind) @endforeach @foreach (PaymentBasis::cases() as $basis) @endforeach @can('money.quotes') @if ($form->payment_basis === 'monthly_fee') @endif @endcan
{{ __('jobs.sections.members') }}
@foreach ($staffOptions as $user) @endforeach @foreach ($staffOptions as $user) @endforeach @foreach ($staffOptions as $user) @endforeach @foreach ($this->contacts as $contact) @endforeach @foreach ($this->billingUnits as $billingUnit) @endforeach
{{ __('jobs.sections.extra') }} {{-- Tags: free text with suggestions from earlier tags, added one at a time. --}}
@foreach ($this->tagSuggestions as $suggestion) @endforeach

{{ __('jobs.fields.tags') }}

@if ($form->tags === [])

{{ __('jobs.tags.none') }}

@else
    @foreach ($form->tags as $index => $tag)
  • {{ $tag }}
  • @endforeach
@endif @error('form.tags')

{{ $message }}

@enderror
{{-- Links: title and address per row. --}}

{{ __('jobs.fields.links') }}

@if ($form->links === [])

{{ __('jobs.links.none') }}

@endif @foreach ($form->links as $index => $link)
{{ __('jobs.links.link_number', ['number' => $index + 1]) }}
@endforeach @error('form.links')

{{ $message }}

@enderror