@@ -40,8 +40,9 @@ class ContentVersionHistory extends RelationManager implements HasActions, HasFo
4040 public function table (Table $ table ): Table
4141 {
4242 return $ table
43- ->modifyQueryUsing (fn ($ query ) => $ query
44- ->with (['publishLog ' , 'author ' ])
43+ ->modifyQueryUsing (
44+ fn ($ query ) => $ query
45+ ->with (['publishLog ' , 'author ' ])
4546 )
4647 ->defaultSort ('created_at ' , 'desc ' )
4748 ->heading ('' )
@@ -67,12 +68,12 @@ public function table(Table $table): Table
6768 ]),
6869 TextColumn::make ('publish_state ' )
6970 ->badge ()
70- ->getStateUsing (fn ($ record ) => !blank ($ record ->publish_state ) ? inspirecms_content_statuses ()->getOption ($ record ->publish_state ) : null )
71+ ->getStateUsing (fn ($ record ) => ! blank ($ record ->publish_state ) ? inspirecms_content_statuses ()->getOption ($ record ->publish_state ) : null )
7172 ->formatStateUsing (fn ($ state ) => $ state instanceof ContentStatusOption ? $ state ->getLabel () : null )
7273 ->color (fn ($ state ) => $ state instanceof ContentStatusOption ? $ state ->getColor () : 'gray ' )
7374 ->placeholder (__ ('inspirecms::inspirecms.n/a ' ))
74- ->icon (function ($ state , ContentVersion | Model $ record ) {
75-
75+ ->icon (function ($ state , ContentVersion | Model $ record ) {
76+
7677 if (($ unpublishOption = ContentStatusManifest::getOption ('unpublish ' ))) {
7778 if ($ state instanceof ContentStatusOption) {
7879 $ state = $ state ->getValue ();
@@ -87,7 +88,7 @@ public function table(Table $table): Table
8788 }
8889
8990 return null ;
90- })
91+ }),
9192 ]),
9293 ]),
9394
@@ -100,6 +101,7 @@ public function table(Table $table): Table
100101 if (empty ($ state ) || ! $ state instanceof DateTimeInterface) {
101102 return null ;
102103 }
104+
103105 return ' ( ' . $ state ->diffForHumans () . ') ' ;
104106 })
105107 ->color ('primary ' )
@@ -121,17 +123,18 @@ public function table(Table $table): Table
121123
122124 $ record ->avoid_to_clean = ! $ record ->avoid_to_clean ;
123125 $ record ->save ();
124- $ record ->refresh ();
126+ $ record ->refresh ();
125127
126128 $ notificationConfig = $ this ->getAvoidToCleanNotificationConfig ($ record ->avoid_to_clean );
127129 $ notificationTitle = $ notificationConfig ['title ' ] ?? null ;
128130
129131 if (filled ($ notificationTitle )) {
130- $ action ->successNotification (fn (Notification $ notification ) => $ notification
131- ->icon (FilamentIcon::resolve ('inspirecms::warn ' ))
132- ->title ($ notificationTitle )
133- ->body ($ notificationConfig ['body ' ] ?? null )
134- ->status ($ notificationConfig ['status ' ] ?? null )
132+ $ action ->successNotification (
133+ fn (Notification $ notification ) => $ notification
134+ ->icon (FilamentIcon::resolve ('inspirecms::warn ' ))
135+ ->title ($ notificationTitle )
136+ ->body ($ notificationConfig ['body ' ] ?? null )
137+ ->status ($ notificationConfig ['status ' ] ?? null )
135138 );
136139 }
137140 $ action ->success ();
@@ -155,7 +158,7 @@ public function table(Table $table): Table
155158 'diff ' => collect ($ this ->getDiffKeysFromRecord ($ record ))
156159 ->mapWithKeys (fn ($ key ) => [
157160 $ key => $ this ->computeDiff (
158- originalContent: $ record ->from_data [$ key ] ?? null ,
161+ originalContent: $ record ->from_data [$ key ] ?? null ,
159162 newContent: $ record ->to_data [$ key ] ?? null
160163 ),
161164 ])
@@ -205,7 +208,7 @@ public function table(Table $table): Table
205208 ->placeholder ('All States ' ),
206209 TernaryFilter::make ('avoid_to_clean ' )
207210 ->label (__ ('inspirecms::resources/content-version.avoid_to_clean.label ' )),
208-
211+
209212 ]);
210213 }
211214
@@ -221,6 +224,7 @@ protected function configureTableAction(TableAction $action): void
221224 if (is_null ($ record )) {
222225 return true ;
223226 }
227+
224228 return ! $ record ->exists && ! $ record instanceof ContentVersion;
225229 });
226230 }
@@ -231,7 +235,7 @@ protected function configureTableBulkAction(TableBulkAction $action): void
231235
232236 $ action
233237 ->hidden (function ($ arguments ) {
234- return ( $ this ->getOwnerRecord ()->isLocked () || $ this ->getOwnerRecord ()->trashed () );
238+ return $ this ->getOwnerRecord ()->isLocked () || $ this ->getOwnerRecord ()->trashed ();
235239 });
236240 }
237241
@@ -242,13 +246,15 @@ protected function computeDiff($originalContent, $newContent)
242246 return collect ($ newContent )
243247 ->map (function ($ item , $ itemKey ) use ($ originalContent ) {
244248 $ oldItem = $ originalContent [$ itemKey ] ?? null ;
249+
245250 return $ this ->computeDiff ($ oldItem , $ item );
246251 })
247252 ->all ();
248- } elseif (!is_array ($ newContent ) && is_array ($ originalContent )) {
253+ } elseif (! is_array ($ newContent ) && is_array ($ originalContent )) {
249254 return collect ($ originalContent )
250255 ->map (function ($ item , $ itemKey ) use ($ newContent ) {
251256 $ newItem = $ newContent [$ itemKey ] ?? null ;
257+
252258 return $ this ->computeDiff ($ item , $ newItem );
253259 })
254260 ->all ();
@@ -270,7 +276,7 @@ protected function computeDiff($originalContent, $newContent)
270276 } catch (\Exception $ e ) {
271277 return __ ('inspirecms::inspirecms.n/a ' );
272278 }
273- }
279+ }
274280
275281 protected function getDiffKeysFromRecord (Model | ContentVersion $ record ): array
276282 {
@@ -303,7 +309,7 @@ protected function getAvoidToCleanActionConfigFromRecord(Model | ContentVersion
303309
304310 protected function getAvoidToCleanNotificationConfig ($ newState )
305311 {
306- if (!is_bool ($ newState )) {
312+ if (! is_bool ($ newState )) {
307313 return [];
308314 }
309315 // Now: avoid to clean = true
@@ -318,6 +324,7 @@ protected function getAvoidToCleanNotificationConfig($newState)
318324 $ body = __ ('inspirecms::resources/content-version.buttons.toggle_avoid_to_clean.messages.wait_to_cleanup.body ' );
319325 $ status = 'info ' ;
320326 }
327+
321328 return compact ('title ' , 'body ' , 'status ' );
322329 }
323330}
0 commit comments