66use Eclipse \Cms \Rules \BannerImageDimensionRule ;
77use Eclipse \Common \Filament \Tables \Columns \ImageColumn ;
88use Eclipse \Common \Helpers \MediaHelper ;
9+ use Filament \Actions ;
910use Filament \Forms ;
10- use Filament \Forms \Components \FileUpload ;
11- use Filament \Forms \Form ;
12- use Filament \Forms \Get ;
1311use Filament \Infolists ;
14- use Filament \Infolists \Infolist ;
15- use Filament \Resources \RelationManagers \Concerns \Translatable ;
1612use Filament \Resources \RelationManagers \RelationManager ;
13+ use Filament \Schemas \Components \Grid ;
14+ use Filament \Schemas \Components \Utilities \Get ;
15+ use Filament \Schemas \Schema ;
1716use Filament \Tables ;
1817use Filament \Tables \Table ;
1918use Illuminate \Database \Eloquent \Builder ;
2019use Illuminate \Database \Eloquent \SoftDeletingScope ;
20+ use LaraZeus \SpatieTranslatable \Actions \LocaleSwitcher ;
21+ use LaraZeus \SpatieTranslatable \Resources \RelationManagers \Concerns \Translatable ;
2122
2223class BannerRelationManager extends RelationManager
2324{
@@ -49,11 +50,10 @@ protected function getDynamicImageColumns(): array
4950 $ locale = $ this ->activeLocale ?? app ()->getLocale ();
5051 $ image = $ record ->images ->where ('type_id ' , $ imageType ->id )->first ();
5152
52- if ($ image && $ image ->getTranslation ('file ' , $ locale )) {
53+ if ($ image? ->getTranslation('file ' , $ locale )) {
5354 return $ image ->getTranslation ('file ' , $ locale );
5455 }
5556
56- // Fallback for test environment when MediaHelper is not autoloaded
5757 if (class_exists (MediaHelper::class)) {
5858 return MediaHelper::getPlaceholderImageUrl (
5959 'Not Found ' ,
@@ -74,12 +74,12 @@ protected function getDynamicImageColumns(): array
7474 })->toArray ();
7575 }
7676
77- public function form (Form $ form ): Form
77+ public function form (Schema $ schema ): Schema
7878 {
79- return $ form
80- ->schema ([
81- Forms \ Components \Section ::make ()
82- ->compact ()
79+ return $ schema
80+ ->components ([
81+ Grid ::make ()
82+ ->columnSpanFull ()
8383 ->schema ([
8484 Forms \Components \TextInput::make ('name ' )
8585 ->required ()
@@ -106,7 +106,7 @@ public function form(Form $form): Form
106106 Forms \Components \Hidden::make ('is_hidpi ' ),
107107 Forms \Components \Hidden::make ('image_width ' ),
108108 Forms \Components \Hidden::make ('image_height ' ),
109- FileUpload::make ('file ' )
109+ Forms \ Components \ FileUpload::make ('file ' )
110110 ->hiddenLabel ()
111111 ->image ()
112112 ->directory ('banners ' )
@@ -213,10 +213,10 @@ function (Get $get): BannerImageDimensionRule|string {
213213 ]);
214214 }
215215
216- public function infolist (Infolist $ infolist ): Infolist
216+ public function infolist (Schema $ schema ): Schema
217217 {
218- return $ infolist
219- ->schema ([
218+ return $ schema
219+ ->components ([
220220 Infolists \Components \TextEntry::make ('name ' ),
221221
222222 Infolists \Components \TextEntry::make ('link ' )
@@ -230,15 +230,14 @@ public function infolist(Infolist $infolist): Infolist
230230 ->boolean ()
231231 ->label ('Open in new tab ' ),
232232
233- Infolists \ Components \ Grid::make ()
233+ Grid::make ()
234234 ->columnSpanFull ()
235235 ->schema (
236236 fn (Banner $ record ) => $ this ->getOwnerRecord ()->imageTypes ()->get ()
237237 ->map (function ($ imageType ) use ($ record ) {
238238 $ locale = app ()->getLocale ();
239239 $ image = $ record ->images ->where ('type_id ' , $ imageType ->id )->first ();
240240
241- // Only show image entry if there's an actual image
242241 if (! $ image || ! $ image ->getTranslation ('file ' , $ locale )) {
243242 return null ;
244243 }
@@ -250,7 +249,7 @@ public function infolist(Infolist $infolist): Infolist
250249 ->height ('auto ' )
251250 ->getStateUsing (fn () => $ image ->getTranslation ('file ' , $ locale ));
252251 })
253- ->filter () // Remove null entries
252+ ->filter ()
254253 ->toArray ()
255254 ),
256255 ]);
@@ -306,8 +305,8 @@ public function table(Table $table): Table
306305 ])
307306 ->reorderable ('sort ' )
308307 ->headerActions ([
309- Tables \ Actions \ LocaleSwitcher::make (),
310- Tables \ Actions \CreateAction::make ()
308+ LocaleSwitcher::make (),
309+ Actions \CreateAction::make ()
311310 ->icon ('heroicon-o-plus-circle ' )
312311 ->label ('Add banner ' )
313312 ->mutateFormDataUsing (function (array $ data ): array {
@@ -319,13 +318,13 @@ public function table(Table $table): Table
319318 }),
320319 ])
321320 ->actions ([
322- Tables \ Actions \ViewAction::make (),
323- Tables \ Actions \EditAction::make (),
324- Tables \ Actions \DeleteAction::make (),
321+ Actions \ViewAction::make (),
322+ Actions \EditAction::make (),
323+ Actions \DeleteAction::make (),
325324 ])
326325 ->bulkActions ([
327- Tables \ Actions \BulkActionGroup::make ([
328- Tables \ Actions \DeleteBulkAction::make (),
326+ Actions \BulkActionGroup::make ([
327+ Actions \DeleteBulkAction::make (),
329328 ]),
330329 ])
331330 ->modifyQueryUsing (
0 commit comments