diff options
author | Sam Light <samlight1994@gmail.com> | 2025-04-02 22:23:36 +0100 |
---|---|---|
committer | Sam Light <samlight1994@gmail.com> | 2025-04-02 22:23:36 +0100 |
commit | 92c1347350f4d6b234fd5f54b4c3baaf7160bccf (patch) | |
tree | 7a4c66ccc2d3f69c483ab8d046b2756d19ce965d | |
parent | 7ecb2fe7590c848ad9f954c2d5961a95219fcfe2 (diff) |
Changed adding items to prepend and append
-rw-r--r-- | src/Toolbar.php | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/src/Toolbar.php b/src/Toolbar.php index 8539e0e..27d495d 100644 --- a/src/Toolbar.php +++ b/src/Toolbar.php @@ -30,7 +30,7 @@ class Toolbar $this->filterItems = collect(); } - private function addItem(Collection $list, ToolbarItem $item): static + private function processItem(ToolbarItem $item): void { $item->setToolbar($this); @@ -43,24 +43,50 @@ class Toolbar 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 addStartItem(ToolbarItem $item): static + public function prependStartItem(ToolbarItem $item): static + { + return $this->prependItem($this->startItems, $item); + } + + public function appendStartItem(ToolbarItem $item): static + { + return $this->appendItem($this->startItems, $item); + } + + public function prependMidItem(ToolbarItem $item): static + { + return $this->prependItem($this->midItems, $item); + } + + public function appendMidItem(ToolbarItem $item): static { - return $this->addItem($this->startItems, $item); + return $this->appendItem($this->midItems, $item); } - public function addMidItem(ToolbarItem $item): static + public function prependEndItem(ToolbarItem $item): static { - return $this->addItem($this->midItems, $item); + return $this->prependItem($this->endItems, $item); } - public function addEndItem(ToolbarItem $item): static + public function appendEndItem(ToolbarItem $item): static { - return $this->addItem($this->endItems, $item); + return $this->appendItem($this->endItems, $item); } public function getTable(): TableComponent |