File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change 16
16
use Filament \Tables \Actions \ActionGroup ;
17
17
use Filament \Tables \Columns \TextColumn ;
18
18
use Filament \Tables \Table ;
19
+ use Illuminate \Contracts \Database \Eloquent \Builder ;
19
20
use Illuminate \Support \Str ;
20
21
21
22
class ArticleResource extends Resource
@@ -72,10 +73,12 @@ public static function table(Table $table): Table
72
73
->sortable (),
73
74
74
75
TextColumn::make ('published_at ' )
75
- ->dateTime ('M j, Y H:i ' )
76
- ->sortable ()
77
76
->badge ()
78
- ->color (fn ($ state ) => $ state && $ state ->isPast () ? 'success ' : 'warning ' ),
77
+ ->dateTime ('M j, Y H:i ' )
78
+ ->color (fn ($ state ) => $ state && $ state ->isPast () ? 'success ' : 'warning ' )
79
+ ->sortable (query: function (Builder $ query , string $ direction ): Builder {
80
+ return $ query ->orderByRaw ("published_at IS NULL {$ direction }, published_at {$ direction }" );
81
+ }),
79
82
])
80
83
->filters ([
81
84
//
You can’t perform that action at this time.
0 commit comments