From 536fa6c917d63b14feeb8f876e6a1d62acb577fc Mon Sep 17 00:00:00 2001 From: Sam Light Date: Thu, 12 Feb 2026 00:23:02 +0000 Subject: Created new dropdown toolbar item --- src/Toolbar/Concerns/WithAction.php | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/Toolbar/Concerns/WithAction.php (limited to 'src/Toolbar/Concerns/WithAction.php') diff --git a/src/Toolbar/Concerns/WithAction.php b/src/Toolbar/Concerns/WithAction.php new file mode 100644 index 0000000..a1c33f2 --- /dev/null +++ b/src/Toolbar/Concerns/WithAction.php @@ -0,0 +1,33 @@ +} $action + */ + public function action(string|array $action): static + { + if (is_array($action)) { + $fn = array_shift($action); + $params = collect($action)->map( + fn ($v) => match (strtolower(gettype($v))) { + 'string' => "'{$v}'", + 'boolean' => $v ? 'true' : 'false', + 'null' => 'null', + default => (string) $v, + } + )->join(', '); + $this->action = "{$fn}({$params})"; + } else { + $this->action = $action; + } + + return $this; + } +} -- cgit v1.2.3