authorize('inventory.view'); } /** * @return list */ #[Computed] public function items(): array { return app(StockQueries::class)->items( $this->search, $this->group === '' ? null : (int) $this->group, $this->onlyReorder, $this->includeInactive && Gate::allows('inventory.manage'), ); } /** * @return list */ #[Computed] public function groups(): array { return app(StockQueries::class)->groups(includeInactive: false); } public function updated(): void { $this->authorize('inventory.view'); unset($this->items); } /** * @return list */ public function headers(): array { $headers = [ ['index' => 'name', 'label' => __('inventory.columns.name'), 'sortable' => false], ['index' => 'group', 'label' => __('inventory.columns.group'), 'sortable' => false], ['index' => 'balance', 'label' => __('inventory.columns.balance'), 'sortable' => false, 'align' => 'right'], ['index' => 'reorder', 'label' => __('inventory.columns.reorder_level'), 'sortable' => false, 'align' => 'right'], ['index' => 'status', 'label' => __('inventory.columns.status'), 'sortable' => false], ]; if (Gate::allows('inventory.see-value')) { $headers[] = ['index' => 'cost', 'label' => __('inventory.columns.average_cost'), 'sortable' => false, 'align' => 'right']; $headers[] = ['index' => 'value', 'label' => __('inventory.columns.value'), 'sortable' => false, 'align' => 'right']; } return $headers; } public function render(): mixed { return $this->view()->title(__('inventory.index.title')); } }; ?>
{{ __('inventory.index.title') }}

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

@can('inventory.manage')
@endcan
{{-- TallStackUI's native select does not tie its label to the control, so aria-label names it. --}} @foreach ($this->groups as $option) @endforeach
@can('inventory.manage') @endcan

{{ trans_choice('inventory.index.count', count($this->items), ['count' => count($this->items)]) }}

@if ($this->items === []) {{ __('inventory.index.none') }} @else @interact('column_name', $item) {{ $item->name }} @if ($item->code !== null) {{ $item->code }} @endif @endinteract @interact('column_group', $item) {{ $item->groupName }} @endinteract @interact('column_balance', $item) {{ $this->quantity($item->balanceMilli, $item->unit) }} @endinteract @interact('column_reorder', $item) {{ $item->reorderLevelMilli === null ? '–' : $this->quantity($item->reorderLevelMilli, $item->unit) }} @endinteract @interact('column_status', $item) @endinteract @interact('column_cost', $item) {{ $this->unitCost($item->averageCostHundredths) }} @endinteract @interact('column_value', $item) {{ $this->money($item->valueCents) }} @endinteract @can('inventory.see-value')

{{ __('inventory.index.total_value', ['value' => $this->money(array_sum(array_map(fn ($item) => $item->valueCents, $this->items)))]) }}

@endcan @endif