22
33namespace Eclipse \World \Filament \Clusters \World \Resources ;
44
5- use BezhanSalleh \ FilamentShield \ Contracts \ HasShieldPermissions ;
5+ use Closure ;
66use Eclipse \World \Filament \Clusters \World ;
7- use Eclipse \World \Filament \Clusters \World \Resources \CountryResource \Pages ;
7+ use Eclipse \World \Filament \Clusters \World \Resources \CountryResource \Pages \ ListCountries ;
88use Eclipse \World \Models \Country ;
9+ use Eclipse \World \Models \CountryInSpecialRegion ;
10+ use Eclipse \World \Models \Region ;
11+ use Filament \Actions \ActionGroup ;
12+ use Filament \Actions \BulkActionGroup ;
13+ use Filament \Actions \DeleteAction ;
14+ use Filament \Actions \DeleteBulkAction ;
15+ use Filament \Actions \EditAction ;
16+ use Filament \Actions \ForceDeleteAction ;
17+ use Filament \Actions \ForceDeleteBulkAction ;
18+ use Filament \Actions \RestoreAction ;
19+ use Filament \Actions \RestoreBulkAction ;
920use Filament \Forms \Components \DatePicker ;
1021use Filament \Forms \Components \Repeater ;
1122use Filament \Forms \Components \Select ;
1223use Filament \Forms \Components \TextInput ;
13- use Filament \Forms \Form ;
1424use Filament \Resources \Resource ;
15- use Filament \Tables \Actions \ActionGroup ;
16- use Filament \Tables \Actions \BulkActionGroup ;
17- use Filament \Tables \Actions \DeleteAction ;
18- use Filament \Tables \Actions \DeleteBulkAction ;
19- use Filament \Tables \Actions \EditAction ;
20- use Filament \Tables \Actions \ForceDeleteAction ;
21- use Filament \Tables \Actions \ForceDeleteBulkAction ;
22- use Filament \Tables \Actions \RestoreAction ;
23- use Filament \Tables \Actions \RestoreBulkAction ;
25+ use Filament \Schemas \Schema ;
2426use Filament \Tables \Columns \TextColumn ;
2527use Filament \Tables \Filters \SelectFilter ;
2628use Filament \Tables \Filters \TrashedFilter ;
2729use Filament \Tables \Table ;
2830use Illuminate \Database \Eloquent \Builder ;
2931use Illuminate \Database \Eloquent \SoftDeletingScope ;
32+ use TangoDevIt \FilamentEmojiPicker \EmojiPickerAction ;
3033
31- class CountryResource extends Resource implements HasShieldPermissions
34+ class CountryResource extends Resource
3235{
3336 protected static ?string $ model = Country::class;
3437
3538 protected static ?string $ slug = 'countries ' ;
3639
37- protected static ? string $ navigationIcon = 'heroicon-o-rectangle-stack ' ;
40+ protected static string | \ BackedEnum | null $ navigationIcon = 'heroicon-o-rectangle-stack ' ;
3841
3942 protected static ?string $ cluster = World::class;
4043
41- public static function form (Form $ form ): Form
44+ public static function form (Schema $ schema ): Schema
4245 {
43- return $ form
44- ->schema ([
46+ return $ schema
47+ ->components ([
4548 TextInput::make ('id ' )
4649 ->required ()
4750 ->length (2 )
@@ -57,7 +60,7 @@ public static function form(Form $form): Form
5760 ->label (__ ('eclipse-world::countries.form.flag.label ' ))
5861 ->suffixAction (function () {
5962 if (class_exists ('\TangoDevIt\FilamentEmojiPicker\EmojiPickerAction ' )) {
60- return \ TangoDevIt \ FilamentEmojiPicker \ EmojiPickerAction::make ('emoji-flag ' );
63+ return EmojiPickerAction::make ('emoji-flag ' );
6164 }
6265
6366 return null ;
@@ -98,7 +101,7 @@ public static function form(Form $form): Form
98101 ->label (__ ('eclipse-world::countries.form.special_regions.region_label ' ))
99102 ->rules ([
100103 function ($ get ) {
101- return function (string $ attribute , $ value , \ Closure $ fail ) use ($ get ) {
104+ return function (string $ attribute , $ value , Closure $ fail ) use ($ get ) {
102105 if (! $ value ) {
103106 return ;
104107 }
@@ -111,7 +114,7 @@ function ($get) {
111114 }
112115
113116 // Check for any existing membership with same country and region
114- $ query = \ Eclipse \ World \ Models \ CountryInSpecialRegion::where ('country_id ' , $ countryId )
117+ $ query = CountryInSpecialRegion::where ('country_id ' , $ countryId )
115118 ->where ('region_id ' , $ value );
116119
117120 // Exclude current record when editing
@@ -120,7 +123,7 @@ function ($get) {
120123 }
121124
122125 if ($ query ->exists ()) {
123- $ regionName = \ Eclipse \ World \ Models \ Region::find ($ value )?->name ?? __ ('eclipse-world::countries.validation.unknown_region ' );
126+ $ regionName = Region::find ($ value )?->name ?? __ ('eclipse-world::countries.validation.unknown_region ' );
124127 $ fail (__ ('eclipse-world::countries.validation.duplicate_special_region_membership ' , [
125128 'region ' => $ regionName ,
126129 ]));
@@ -195,7 +198,7 @@ public static function table(Table $table): Table
195198 SelectFilter::make ('special_regions ' )
196199 ->label (__ ('eclipse-world::countries.filters.special_region.label ' ))
197200 ->options (function () {
198- return \ Eclipse \ World \ Models \ Region::where ('is_special ' , true )
201+ return Region::where ('is_special ' , true )
199202 ->pluck ('name ' , 'id ' )
200203 ->toArray ();
201204 })
@@ -217,7 +220,7 @@ public static function table(Table $table): Table
217220 ->preload (),
218221 TrashedFilter::make (),
219222 ])
220- ->actions ([
223+ ->recordActions ([
221224 EditAction::make ()
222225 ->label (__ ('eclipse-world::countries.actions.edit.label ' ))
223226 ->modalHeading (__ ('eclipse-world::countries.actions.edit.heading ' )),
@@ -236,7 +239,7 @@ public static function table(Table $table): Table
236239 ])),
237240 ]),
238241 ])
239- ->bulkActions ([
242+ ->toolbarActions ([
240243 BulkActionGroup::make ([
241244 DeleteBulkAction::make ()
242245 ->label (__ ('eclipse-world::countries.actions.delete.label ' )),
@@ -251,7 +254,7 @@ public static function table(Table $table): Table
251254 public static function getPages (): array
252255 {
253256 return [
254- 'index ' => Pages \ ListCountries::route ('/ ' ),
257+ 'index ' => ListCountries::route ('/ ' ),
255258 ];
256259 }
257260
@@ -263,21 +266,6 @@ public static function getEloquentQuery(): Builder
263266 ]);
264267 }
265268
266- public static function getPermissionPrefixes (): array
267- {
268- return [
269- 'view_any ' ,
270- 'create ' ,
271- 'update ' ,
272- 'restore ' ,
273- 'restore_any ' ,
274- 'delete ' ,
275- 'delete_any ' ,
276- 'force_delete ' ,
277- 'force_delete_any ' ,
278- ];
279- }
280-
281269 public static function getNavigationLabel (): string
282270 {
283271 return __ ('eclipse-world::countries.nav_label ' );
0 commit comments