|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Usamamuneerchaudhary\Notifier\Filament\Resources\NotificationResource\Tables; |
|
4
|
|
|
|
|
5
|
|
|
use Filament\Actions\Action; |
|
6
|
|
|
use Filament\Actions\BulkActionGroup; |
|
7
|
|
|
use Filament\Actions\DeleteBulkAction; |
|
8
|
|
|
use Filament\Actions\ViewAction; |
|
|
|
|
|
|
9
|
|
|
use Filament\Forms\Components\DatePicker; |
|
10
|
|
|
use Filament\Tables\Columns\BadgeColumn; |
|
11
|
|
|
use Filament\Tables\Columns\TextColumn; |
|
12
|
|
|
use Filament\Tables\Filters\Filter; |
|
13
|
|
|
use Filament\Tables\Filters\SelectFilter; |
|
14
|
|
|
use Filament\Tables\Table; |
|
15
|
|
|
|
|
16
|
|
|
class NotificationTable |
|
17
|
|
|
{ |
|
18
|
|
|
|
|
19
|
|
|
public static function configure(Table $table): Table |
|
20
|
|
|
{ |
|
21
|
|
|
return $table |
|
22
|
|
|
->columns([ |
|
23
|
|
|
TextColumn::make('template.name') |
|
24
|
|
|
->searchable() |
|
25
|
|
|
->sortable(), |
|
26
|
|
|
TextColumn::make('user.name') |
|
27
|
|
|
->searchable() |
|
28
|
|
|
->sortable(), |
|
29
|
|
|
BadgeColumn::make('channel') |
|
30
|
|
|
->colors([ |
|
31
|
|
|
'primary' => 'email', |
|
32
|
|
|
'success' => 'sms', |
|
33
|
|
|
'warning' => 'slack', |
|
34
|
|
|
'danger' => 'push', |
|
35
|
|
|
]), |
|
36
|
|
|
TextColumn::make('subject') |
|
37
|
|
|
->limit(50) |
|
38
|
|
|
->searchable(), |
|
39
|
|
|
BadgeColumn::make('status') |
|
40
|
|
|
->colors([ |
|
41
|
|
|
'warning' => 'pending', |
|
42
|
|
|
'success' => 'sent', |
|
43
|
|
|
'danger' => 'failed', |
|
44
|
|
|
]), |
|
45
|
|
|
TextColumn::make('scheduled_at') |
|
46
|
|
|
->dateTime() |
|
47
|
|
|
->sortable(), |
|
48
|
|
|
TextColumn::make('sent_at') |
|
49
|
|
|
->dateTime() |
|
50
|
|
|
->sortable(), |
|
51
|
|
|
TextColumn::make('created_at') |
|
52
|
|
|
->dateTime() |
|
53
|
|
|
->sortable(), |
|
54
|
|
|
]) |
|
55
|
|
|
->filters([ |
|
56
|
|
|
SelectFilter::make('channel') |
|
57
|
|
|
->options([ |
|
58
|
|
|
'email' => 'Email', |
|
59
|
|
|
'sms' => 'SMS', |
|
60
|
|
|
'slack' => 'Slack', |
|
61
|
|
|
'push' => 'Push Notification', |
|
62
|
|
|
]), |
|
63
|
|
|
SelectFilter::make('status') |
|
64
|
|
|
->options([ |
|
65
|
|
|
'pending' => 'Pending', |
|
66
|
|
|
'sent' => 'Sent', |
|
67
|
|
|
'failed' => 'Failed', |
|
68
|
|
|
]), |
|
69
|
|
|
Filter::make('scheduled_at') |
|
|
|
|
|
|
70
|
|
|
->form([ |
|
71
|
|
|
DatePicker::make('scheduled_from'), |
|
72
|
|
|
DatePicker::make('scheduled_until'), |
|
73
|
|
|
]) |
|
74
|
|
|
->query(function ($query, array $data) { |
|
75
|
|
|
return $query |
|
76
|
|
|
->when( |
|
77
|
|
|
$data['scheduled_from'], |
|
78
|
|
|
fn($query) => $query->whereDate('scheduled_at', '>=', $data['scheduled_from']) |
|
79
|
|
|
) |
|
80
|
|
|
->when( |
|
81
|
|
|
$data['scheduled_until'], |
|
82
|
|
|
fn($query) => $query->whereDate('scheduled_at', '<=', $data['scheduled_until']) |
|
83
|
|
|
); |
|
84
|
|
|
}), |
|
85
|
|
|
]) |
|
86
|
|
|
->recordActions([ |
|
87
|
|
|
ViewAction::make(), |
|
88
|
|
|
Action::make('resend') |
|
89
|
|
|
->icon('heroicon-o-arrow-path') |
|
90
|
|
|
->color('warning') |
|
91
|
|
|
->requiresConfirmation() |
|
92
|
|
|
->visible(fn($record) => $record->status === 'failed') |
|
93
|
|
|
->action(function ($record) { |
|
94
|
|
|
// Resend the notification |
|
95
|
|
|
$record->update(['status' => 'pending']); |
|
96
|
|
|
\Usamamuneerchaudhary\Notifier\Jobs\SendNotificationJob::dispatch($record->id); |
|
97
|
|
|
}), |
|
98
|
|
|
]) |
|
99
|
|
|
->toolbarActions([ |
|
100
|
|
|
BulkActionGroup::make([ |
|
101
|
|
|
DeleteBulkAction::make(), |
|
102
|
|
|
]), |
|
103
|
|
|
]) |
|
104
|
|
|
->defaultSort('created_at', 'desc'); |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
} |
|
108
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths