@@ -45,8 +45,9 @@ public function getTableRecordTitle(Model $record): ?string
4545 public function table (Table $ table ): Table
4646 {
4747 return $ table
48- ->modifyQueryUsing (fn ($ query ) => $ query
49- ->with (['publishLog ' , 'author ' ])
48+ ->modifyQueryUsing (
49+ fn ($ query ) => $ query
50+ ->with (['publishLog ' , 'author ' ])
5051 )
5152 ->defaultSort ('created_at ' , 'desc ' )
5253 ->heading ('' )
@@ -76,12 +77,12 @@ public function table(Table $table): Table
7677 ]),
7778 TextColumn::make ('publish_state ' )
7879 ->badge ()
79- ->getStateUsing (fn ($ record ) => !blank ($ record ->publish_state ) ? inspirecms_content_statuses ()->getOption ($ record ->publish_state ) : null )
80+ ->getStateUsing (fn ($ record ) => ! blank ($ record ->publish_state ) ? inspirecms_content_statuses ()->getOption ($ record ->publish_state ) : null )
8081 ->formatStateUsing (fn ($ state ) => $ state instanceof ContentStatusOption ? $ state ->getLabel () : null )
8182 ->color (fn ($ state ) => $ state instanceof ContentStatusOption ? $ state ->getColor () : 'gray ' )
8283 ->placeholder (__ ('inspirecms::inspirecms.n/a ' ))
83- ->icon (function ($ state , ContentVersion | Model $ record ) {
84-
84+ ->icon (function ($ state , ContentVersion | Model $ record ) {
85+
8586 if (($ unpublishOption = ContentStatusManifest::getOption ('unpublish ' ))) {
8687 if ($ state instanceof ContentStatusOption) {
8788 $ state = $ state ->getValue ();
@@ -96,7 +97,7 @@ public function table(Table $table): Table
9697 }
9798
9899 return null ;
99- })
100+ }),
100101 ]),
101102 ]),
102103
@@ -109,6 +110,7 @@ public function table(Table $table): Table
109110 if (empty ($ state ) || ! $ state instanceof DateTimeInterface) {
110111 return null ;
111112 }
113+
112114 return ' ( ' . $ state ->diffForHumans () . ') ' ;
113115 })
114116 ->color ('primary ' )
@@ -127,17 +129,18 @@ public function table(Table $table): Table
127129
128130 $ record ->avoid_to_clean = ! $ record ->avoid_to_clean ;
129131 $ record ->save ();
130- $ record ->refresh ();
132+ $ record ->refresh ();
131133
132134 $ notificationConfig = $ this ->getAvoidToCleanNotificationConfig ($ record ->avoid_to_clean );
133135 $ notificationTitle = $ notificationConfig ['title ' ] ?? null ;
134136
135137 if (filled ($ notificationTitle )) {
136- $ action ->successNotification (fn (Notification $ notification ) => $ notification
137- ->icon (FilamentIcon::resolve ('inspirecms::warn ' ))
138- ->title ($ notificationTitle )
139- ->body ($ notificationConfig ['body ' ] ?? null )
140- ->status ($ notificationConfig ['status ' ] ?? null )
138+ $ action ->successNotification (
139+ fn (Notification $ notification ) => $ notification
140+ ->icon (FilamentIcon::resolve ('inspirecms::warn ' ))
141+ ->title ($ notificationTitle )
142+ ->body ($ notificationConfig ['body ' ] ?? null )
143+ ->status ($ notificationConfig ['status ' ] ?? null )
141144 );
142145 }
143146 $ action ->success ();
@@ -189,7 +192,7 @@ public function table(Table $table): Table
189192 ->placeholder ('All States ' ),
190193 TernaryFilter::make ('avoid_to_clean ' )
191194 ->label (__ ('inspirecms::resources/content-version.avoid_to_clean.label ' )),
192-
195+
193196 ]);
194197 }
195198
@@ -205,6 +208,7 @@ protected function configureTableAction(TableAction $action): void
205208 if (is_null ($ record )) {
206209 return true ;
207210 }
211+
208212 return ! $ record ->exists && ! $ record instanceof ContentVersion;
209213 });
210214
@@ -250,7 +254,7 @@ protected function configureTableBulkAction(TableBulkAction $action): void
250254
251255 $ action
252256 ->hidden (function ($ arguments ) {
253- return ( $ this ->getOwnerRecord ()->isLocked () || $ this ->getOwnerRecord ()->trashed () );
257+ return $ this ->getOwnerRecord ()->isLocked () || $ this ->getOwnerRecord ()->trashed ();
254258 });
255259 }
256260
@@ -277,13 +281,15 @@ protected function computeDiff($originalContent, $newContent)
277281 return collect ($ newContent )
278282 ->map (function ($ item , $ itemKey ) use ($ originalContent ) {
279283 $ oldItem = $ originalContent [$ itemKey ] ?? null ;
284+
280285 return $ this ->computeDiff ($ oldItem , $ item );
281286 })
282287 ->all ();
283- } elseif (!is_array ($ newContent ) && is_array ($ originalContent )) {
288+ } elseif (! is_array ($ newContent ) && is_array ($ originalContent )) {
284289 return collect ($ originalContent )
285290 ->map (function ($ item , $ itemKey ) use ($ newContent ) {
286291 $ newItem = $ newContent [$ itemKey ] ?? null ;
292+
287293 return $ this ->computeDiff ($ item , $ newItem );
288294 })
289295 ->all ();
@@ -305,7 +311,7 @@ protected function computeDiff($originalContent, $newContent)
305311 } catch (\Exception $ e ) {
306312 return __ ('inspirecms::inspirecms.n/a ' );
307313 }
308- }
314+ }
309315
310316 protected function getDiffKeysFromRecord (Model | ContentVersion $ record ): array
311317 {
@@ -338,7 +344,7 @@ protected function getAvoidToCleanActionConfigFromRecord(Model | ContentVersion
338344
339345 protected function getAvoidToCleanNotificationConfig ($ newState )
340346 {
341- if (!is_bool ($ newState )) {
347+ if (! is_bool ($ newState )) {
342348 return [];
343349 }
344350 // Now: avoid to clean = true
@@ -353,6 +359,7 @@ protected function getAvoidToCleanNotificationConfig($newState)
353359 $ body = __ ('inspirecms::resources/content-version.buttons.toggle_avoid_to_clean.messages.wait_to_cleanup.body ' );
354360 $ status = 'info ' ;
355361 }
362+
356363 return compact ('title ' , 'body ' , 'status ' );
357364 }
358365}
0 commit comments