22
33namespace CodeWithDennis \FilamentTests \Concerns ;
44
5- use Filament \Actions \Action ;
6- use Filament \Resources \Pages \ListRecords ;
7- use Filament \Schemas \Schema ;
8- use Filament \Tables \Columns \Column ;
9- use Filament \Tables \Table ;
5+ use CodeWithDennis \FilamentTests \Concerns \Resources \InteractsWithForms ;
6+ use CodeWithDennis \FilamentTests \Concerns \Resources \InteractsWithModels ;
7+ use CodeWithDennis \FilamentTests \Concerns \Resources \InteractsWithTables ;
108use ReflectionClass ;
119
1210trait InteractsWithResources
1311{
12+ use InteractsWithForms;
13+ use InteractsWithModels;
14+ use InteractsWithTables;
15+
1416 protected function getPrivateProperty (object $ object , string $ property ): mixed
1517 {
1618 $ reflection = new ReflectionClass ($ object );
@@ -19,53 +21,4 @@ protected function getPrivateProperty(object $object, string $property): mixed
1921
2022 return $ property ->getValue ($ object );
2123 }
22-
23- public function getResourceClass (): ?string
24- {
25- return $ this ->resourceClass ;
26- }
27-
28- public function getResource ()
29- {
30- return new ($ this ->getResourceClass ());
31- }
32-
33- public function getResourceModel (): ?string
34- {
35- return $ this ->getResource ()->getModel ();
36- }
37-
38- public function getResourceForm ()
39- {
40- return $ this ->getResource ()->form (new Schema );
41- }
42-
43- public function getResourceTable ()
44- {
45- return $ this ->getResource ()->table (new Table (
46- app ('livewire ' )->new (ListRecords::class)
47- ));
48- }
49-
50- public function getResourceTableColumns (): array
51- {
52- return $ this ->getResourceTable ()->getColumns ();
53- }
54-
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-
67- public function getResourceSortableTableColumns (): array
68- {
69- return array_filter ($ this ->getResourceTableColumns (), fn (Column $ column ) => $ column ->isSortable ());
70- }
7124}
0 commit comments