startItems = collect(); $this->midItems = collect(); $this->endItems = collect(); $this->filterItems = collect(); } private function processItem(ToolbarItem $item): void { $item->setToolbar($this); if ($item instanceof FilterItem) { $this->filterItems->push($item); } else if ($item instanceof PageSizeItem) { $this->pageSizeItem = $item; } else if ($item instanceof SearchItem) { $this->searchItem = $item; } } private function prependItem(Collection $list, ToolbarItem $item): static { $this->processItem($item); $list->prepend($item); return $this; } private function appendItem(Collection $list, ToolbarItem $item): static { $this->processItem($item); $list->push($item); return $this; } public function prependStart(ToolbarItem $item): static { return $this->prependItem($this->startItems, $item); } public function appendStart(ToolbarItem $item): static { return $this->appendItem($this->startItems, $item); } public function prependMid(ToolbarItem $item): static { return $this->prependItem($this->midItems, $item); } public function appendMid(ToolbarItem $item): static { return $this->appendItem($this->midItems, $item); } public function prependEnd(ToolbarItem $item): static { return $this->prependItem($this->endItems, $item); } public function appendEnd(ToolbarItem $item): static { return $this->appendItem($this->endItems, $item); } public function getTable(): TableComponent { return $this->table; } public function getSearch(): ?SearchItem { return $this->searchItem; } public function getPageSize(): ?PageSizeItem { return $this->pageSizeItem; } public function getFilters(): Collection { return $this->filterItems; } public function render(): View { return view('laralight-tables::toolbar', [ 'startItems' => $this->startItems, 'midItems' => $this->midItems, 'endItems' => $this->endItems, ]); } }