diff --git a/packages/tables/resources/views/components/table.blade.php b/packages/tables/resources/views/components/table.blade.php index c4361202f73..8faf869e8ce 100644 --- a/packages/tables/resources/views/components/table.blade.php +++ b/packages/tables/resources/views/components/table.blade.php @@ -89,7 +89,7 @@ class="border-gray-300 rounded shadow-sm text-primary-600 focus:border-primary-6 @endforeach - + @foreach ($table->getRecordActions() as $recordAction) {{ $recordAction->render($record) }} @endforeach diff --git a/packages/tables/src/Table.php b/packages/tables/src/Table.php index 09a35576d86..b9224ea12ec 100644 --- a/packages/tables/src/Table.php +++ b/packages/tables/src/Table.php @@ -204,14 +204,32 @@ public function primaryColumnUrl($url, $shouldOpenInNewTab = false) public function recordActions($actions) { $this->recordActions = collect(value($actions)) - ->map(function ($action) { - return $action->table($this); - }) + ->map(fn ($action) => $action->table($this)) ->toArray(); return $this; } + public function pushRecordActions($actions) + { + $this->recordActions = array_merge( + $this->recordActions, + collect(value($actions))->map(fn ($action) => $action->table($this))->toArray(), + ); + + return $this; + } + + public function prependRecordActions($actions) + { + $this->recordActions = array_merge( + collect(value($actions))->map(fn ($action) => $action->table($this))->toArray(), + $this->recordActions, + ); + + return $this; + } + public function reorder($order) { $callback = $this->reorderUsing;