croustibat/filament-jobs-monitor

the sort of the status filed is not work

alihesahm opened this issue · 1 comments

in the filament resources the sort of the status filed is not work

"Status" is a computed attribute. so i remove sortable and add a filter :

           ->filters([
                SelectFilter::make('status')
                    ->options([
                        'running' => 'Running',
                        'succeeded' => 'Succeeded',
                        'failed' => 'Failed',
                    ])
                    ->query(function (Builder $query, array $data) {
                        if ($data['value'] === 'succeeded') {
                            return $query
                                ->whereNotNull('finished_at')
                                ->where('failed', 0);
                        }
                        else if ($data['value'] === 'failed') {
                            return $query
                                ->whereNotNull('finished_at')
                                ->where('failed', 1);
                        }
                        else if ($data['value'] === 'running') {
                            return $query
                                ->whereNull('finished_at');
                        }
                    }),
            ]);
Screenshot 2023-12-07 at 23 46 59

I'll release the fix in few days ;)