authorize('machines.use'); } /** * @return array Service units that use stock or have machines. */ #[Computed] public function units(): array { $ids = array_unique(array_merge( app(CatalogQueries::class)->stockServiceUnitIds(), ...array_map(fn (MachineSummary $machine): array => $machine->serviceUnitIds, $this->machines), )); return app(CatalogQueries::class)->serviceUnitNames(array_values($ids)); } /** * @return list */ #[Computed] public function machines(): array { return app(MachineQueries::class)->machines($this->includeInactive && Gate::allows('machines.manage')); } /** * Machines by unit name; a shared machine is under each of its units. * * @return array> */ public function grouped(): array { $groups = []; foreach ($this->units as $unitId => $unitName) { if ($this->unit !== '' && (int) $this->unit !== $unitId) { continue; } $machines = array_values(array_filter($this->machines, fn (MachineSummary $machine): bool => in_array($unitId, $machine->serviceUnitIds, true))); if ($machines !== []) { $groups[$unitName] = $machines; } } return $groups; } public function updated(): void { $this->authorize('machines.use'); unset($this->machines, $this->units); } public function render(): mixed { return $this->view()->title(__('machines.index.title')); } }; ?>

{{ __('machines.index.title') }}

{{ __('machines.index.intro') }}

@can('machines.manage')

@endcan
{{-- TallStackUI's native select does not tie its label to the control, so aria-label names it. --}} @foreach ($this->units as $unitId => $unitName) @endforeach
@can('machines.manage') @endcan
@forelse ($this->grouped() as $unitName => $machines)

{{ $unitName }}

    @foreach ($machines as $machine)
  • {{ $machine->name }}

    {{ __('machines.types.'.$machine->type->value) }} @if ($machine->responsibleName !== null) · {{ __('machines.index.responsible', ['name' => $machine->responsibleName]) }} @endif @unless ($machine->isActive) · {{ __('machines.index.inactive') }} @endunless

    {{ __('machines.index.console_named', ['name' => $machine->name]) }}
  • @endforeach
@empty

{{ __('machines.index.none') }}

@endforelse