1111use App \Forms \Components \RecommendationsSection ;
1212use App \Forms \Components \VulnerabilityChips ;
1313use App \Models \Catagraphy ;
14- use Filament \Actions \Action as PageAction ;
14+ use Filament \Forms \ Components \ Actions \Action ;
1515use Filament \Forms \Components \Section ;
1616use Filament \Forms \Components \View ;
1717use Filament \Forms \Form ;
@@ -46,7 +46,7 @@ public function mount(int | string $record): void
4646
4747 $ this ->record = $ this ->beneficiary ->catagraphy ;
4848
49- abort_unless (static :: getResource () ::canView ($ this ->getRecord ()), 403 );
49+ abort_unless (BeneficiaryResource ::canView ($ this ->getRecord ()), 403 );
5050
5151 abort_unless ($ this ->getBeneficiary ()->isRegular (), 404 );
5252
@@ -56,23 +56,19 @@ public function mount(int | string $record): void
5656 public function form (Form $ form ): Form
5757 {
5858 return $ form
59- ->columns (1 )
6059 ->schema ([
6160 Section::make ()
6261 ->heading (__ ('catagraphy.header.vulnerabilities ' ))
63- ->headerActions (function (Catagraphy $ record ) {
64- if (! $ record ->created_at ) {
65- return false ;
66- }
67-
68- return [
69- PageAction::make ('view ' )
70- ->label (__ ('catagraphy.action.view ' ))
71- ->url (static ::getResource ()::getUrl ('catagraphy.view ' , $ this ->getBeneficiary ()))
72- ->color ('gray ' ),
73- ];
74- })
75- ->footer ($ this ->getVulnerabilitiesFooter ())
62+ ->headerActions ([
63+ Action::make ('view ' )
64+ ->label (__ ('catagraphy.action.view ' ))
65+ ->visible (fn (Catagraphy $ record ) => filled ($ record ->created_at ))
66+ ->url (BeneficiaryResource::getUrl ('catagraphy.view ' , [
67+ 'record ' => $ this ->getBeneficiary (),
68+ ]))
69+ ->color ('gray ' ),
70+ ])
71+ // ->footer($this->getVulnerabilitiesFooter())
7672 ->schema ($ this ->getVulnerabilitiesFormSchema ()),
7773
7874 RecommendationsSection::make (),
@@ -91,7 +87,7 @@ protected function getVulnerabilitiesFormSchema(): array
9187 'actions ' => [
9288 TableAction::make ('create ' )
9389 ->label (__ ('catagraphy.vulnerability.empty.create ' ))
94- ->url (static :: getResource () ::getUrl ('catagraphy.edit ' , ['record ' => $ this ->getBeneficiary ()]))
90+ ->url (BeneficiaryResource ::getUrl ('catagraphy.edit ' , ['record ' => $ this ->getBeneficiary ()]))
9591 ->button ()
9692 ->color ('gray ' ),
9793 ],
@@ -127,7 +123,9 @@ protected function getVulnerabilitiesFooter(): ?ViewContract
127123 'created_at ' => $ catagraphy ->created_at ->toFormattedDateTime (),
128124 'updated_at ' => $ catagraphy ->updated_at ->toFormattedDateTime (),
129125 'name ' => $ catagraphy ->nurse ->full_name ,
130- 'history_url ' => static ::getResource ()::getUrl ('history ' , $ this ->getBeneficiary ()),
126+ 'history_url ' => BeneficiaryResource::getUrl ('history ' , [
127+ 'record ' => $ this ->getBeneficiary (),
128+ ]),
131129 ]);
132130 }
133131
0 commit comments