NotificationForm   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
eloc 43
c 1
b 0
f 1
dl 0
loc 48
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A configure() 0 46 2
1
<?php
2
3
namespace Usamamuneerchaudhary\Notifier\Filament\Resources\NotificationResource\Schemas;
4
5
use Filament\Forms\Components\DateTimePicker;
6
use Filament\Forms\Components\KeyValue;
7
use Filament\Forms\Components\Select;
8
use Filament\Forms\Components\Textarea;
9
use Filament\Forms\Components\TextInput;
10
use Filament\Schemas\Components\Section;
11
use Filament\Schemas\Schema;
12
13
class NotificationForm
14
{
15
    public static function configure(Schema $schema): Schema
16
    {
17
        return $schema
18
            ->components([
19
                Section::make()
20
                    ->schema([
21
                        Select::make('notification_template_id')
22
                            ->relationship('template', 'name')
23
                            ->required()
24
                            ->searchable(),
25
                        Select::make('user_id')
26
                            ->relationship('user', 'name')
27
                            ->required()
28
                            ->searchable(),
29
                        Select::make('channel')
30
                            ->options([
31
                                'email' => 'Email',
32
                                'sms' => 'SMS',
33
                                'slack' => 'Slack',
34
                                'discord' => 'Discord',
35
                                'push' => 'Push Notification',
36
                            ])
37
                            ->required(),
38
                        TextInput::make('subject')
39
                            ->maxLength(255),
40
                        Textarea::make('content')
41
                            ->rows(10)
42
                            ->readonly(),
43
                        KeyValue::make('data')
44
                            ->keyLabel('Key')
45
                            ->valueLabel('Value'),
46
                        Select::make('status')
47
                            ->options([
48
                                'pending' => 'Pending',
49
                                'sent' => 'Sent',
50
                                'failed' => 'Failed',
51
                            ])
52
                            ->required(),
53
                        DateTimePicker::make('scheduled_at')
54
                            ->readonly(),
55
                        DateTimePicker::make('sent_at')
56
                            ->readonly(),
57
                        Textarea::make('error')
58
                            ->rows(3)
59
                            ->readonly()
60
                            ->visible(fn($record) => $record && $record->status === 'failed'),
61
                    ])
62
            ]);
63
    }
64
}
65