Skip to content
This repository was archived by the owner on Feb 14, 2026. It is now read-only.

Commit 39a9fd0

Browse files
Add method to get visible actions on resource table
1 parent d4af088 commit 39a9fd0

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/Concerns/InteractsWithResources.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,24 @@
22

33
namespace CodeWithDennis\FilamentTests\Concerns;
44

5+
use Filament\Actions\Action;
56
use Filament\Resources\Pages\ListRecords;
67
use Filament\Schemas\Schema;
78
use Filament\Tables\Columns\Column;
89
use Filament\Tables\Table;
10+
use ReflectionClass;
911

1012
trait InteractsWithResources
1113
{
14+
protected function getPrivateProperty(object $object, string $property): mixed
15+
{
16+
$reflection = new ReflectionClass($object);
17+
$property = $reflection->getProperty($property);
18+
$property->setAccessible(true);
19+
20+
return $property->getValue($object);
21+
}
22+
1223
public function getResourceClass(): ?string
1324
{
1425
return $this->resourceClass;
@@ -41,6 +52,18 @@ public function getResourceTableColumns(): array
4152
return $this->getResourceTable()->getColumns();
4253
}
4354

55+
public function getResourceTableActions(): array
56+
{
57+
return $this->getResourceTable()->getActions();
58+
}
59+
60+
public function getResourceTableVisibleActions(): array
61+
{
62+
return array_filter($this->getResourceTableActions(), function (Action $action) {
63+
return ! $this->getPrivateProperty($action, 'isHidden');
64+
});
65+
}
66+
4467
public function getResourceSortableTableColumns(): array
4568
{
4669
return array_filter($this->getResourceTableColumns(), fn (Column $column) => $column->isSortable());

0 commit comments

Comments
 (0)