ReportsRelationManager::form()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 33
Code Lines 30

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 30
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 33
rs 9.44
1
<?php
2
3
namespace Usamamuneerchaudhary\Commentify\Filament\Resources\CommentResource\RelationManagers;
4
5
use Filament\Forms;
0 ignored issues
show
Bug introduced by
The type Filament\Forms was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Filament\Resources\RelationManagers\RelationManager;
0 ignored issues
show
Bug introduced by
The type Filament\Resources\Relat...anagers\RelationManager was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use Filament\Schemas\Schema;
0 ignored issues
show
Bug introduced by
The type Filament\Schemas\Schema was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Filament\Tables;
0 ignored issues
show
Bug introduced by
The type Filament\Tables was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use Filament\Tables\Table;
0 ignored issues
show
Bug introduced by
The type Filament\Tables\Table was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use Usamamuneerchaudhary\Commentify\Models\CommentReport;
11
12
class ReportsRelationManager extends RelationManager
13
{
14
    protected static string $relationship = 'reports';
15
16
    protected static ?string $title = 'Reports';
17
18
    protected static ?string $recordTitleAttribute = 'id';
19
20
    public function form(Schema $schema): Schema
21
    {
22
        return $schema
23
            ->schema([
24
                Forms\Components\Select::make('user_id')
0 ignored issues
show
Bug introduced by
The type Filament\Forms\Components\Select was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
25
                    ->relationship('user', 'name')
26
                    ->searchable()
27
                    ->nullable()
28
                    ->disabled(),
29
                Forms\Components\TextInput::make('ip')
0 ignored issues
show
Bug introduced by
The type Filament\Forms\Components\TextInput was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
30
                    ->label('IP Address')
31
                    ->disabled(),
32
                Forms\Components\Textarea::make('reason')
0 ignored issues
show
Bug introduced by
The type Filament\Forms\Components\Textarea was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
33
                    ->required()
34
                    ->maxLength(1000)
35
                    ->rows(4)
36
                    ->columnSpanFull()
37
                    ->disabled(),
38
                Forms\Components\Select::make('status')
39
                    ->options([
40
                        'pending' => 'Pending',
41
                        'reviewed' => 'Reviewed',
42
                        'dismissed' => 'Dismissed',
43
                    ])
44
                    ->required()
45
                    ->default('pending'),
46
                Forms\Components\Select::make('reviewed_by')
47
                    ->relationship('reviewer', 'name')
48
                    ->searchable()
49
                    ->nullable()
50
                    ->visible(fn ($get) => $get('status') !== 'pending'),
51
                Forms\Components\DateTimePicker::make('reviewed_at')
0 ignored issues
show
Bug introduced by
The type Filament\Forms\Components\DateTimePicker was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
52
                    ->visible(fn ($get) => $get('status') !== 'pending'),
53
            ]);
54
    }
55
56
    public function table(Table $table): Table
57
    {
58
        return $table
59
            ->recordTitleAttribute('id')
60
            ->columns([
61
                Tables\Columns\TextColumn::make('id')
0 ignored issues
show
Bug introduced by
The type Filament\Tables\Columns\TextColumn was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
62
                    ->label('ID')
63
                    ->sortable(),
64
                Tables\Columns\TextColumn::make('user.name')
65
                    ->label('Reporter')
66
                    ->sortable()
67
                    ->searchable()
68
                    ->default('Guest'),
69
                Tables\Columns\TextColumn::make('ip')
70
                    ->label('IP Address')
71
                    ->searchable()
72
                    ->toggleable(),
73
                Tables\Columns\TextColumn::make('reason')
74
                    ->label('Reason')
75
                    ->limit(50)
76
                    ->wrap()
77
                    ->searchable(),
78
                Tables\Columns\TextColumn::make('status')
79
                    ->badge()
80
                    ->color(fn (string $state): string => match ($state) {
81
                        'pending' => 'warning',
82
                        'reviewed' => 'success',
83
                        'dismissed' => 'danger',
84
                        default => 'gray',
85
                    })
86
                    ->sortable(),
87
                Tables\Columns\TextColumn::make('reviewer.name')
88
                    ->label('Reviewed By')
89
                    ->sortable()
90
                    ->toggleable(),
91
                Tables\Columns\TextColumn::make('reviewed_at')
92
                    ->dateTime()
93
                    ->sortable()
94
                    ->toggleable(),
95
                Tables\Columns\TextColumn::make('created_at')
96
                    ->dateTime()
97
                    ->sortable(),
98
            ])
99
            ->filters([
100
                Tables\Filters\SelectFilter::make('status')
0 ignored issues
show
Bug introduced by
The type Filament\Tables\Filters\SelectFilter was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
101
                    ->options([
102
                        'pending' => 'Pending',
103
                        'reviewed' => 'Reviewed',
104
                        'dismissed' => 'Dismissed',
105
                    ]),
106
            ])
107
            ->headerActions([
108
                // Tables\Actions\CreateAction::make(),
109
            ])
110
            ->recordActions([
111
                \Filament\Actions\ViewAction::make(),
0 ignored issues
show
Bug introduced by
The type Filament\Actions\ViewAction was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
112
                \Filament\Actions\EditAction::make(),
0 ignored issues
show
Bug introduced by
The type Filament\Actions\EditAction was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
113
                \Filament\Actions\Action::make('review')
0 ignored issues
show
Bug introduced by
The type Filament\Actions\Action was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
114
                    ->label('Mark as Reviewed')
115
                    ->icon('heroicon-o-check-circle')
116
                    ->color('success')
117
                    ->requiresConfirmation()
118
                    ->visible(fn (CommentReport $record) => $record->status === 'pending')
119
                    ->action(function (CommentReport $record) {
120
                        $record->update([
121
                            'status' => 'reviewed',
122
                            'reviewed_by' => auth()->id(),
123
                            'reviewed_at' => now(),
124
                        ]);
125
                    }),
126
                \Filament\Actions\Action::make('dismiss')
127
                    ->label('Dismiss')
128
                    ->icon('heroicon-o-x-circle')
129
                    ->color('danger')
130
                    ->requiresConfirmation()
131
                    ->visible(fn (CommentReport $record) => $record->status === 'pending')
132
                    ->action(function (CommentReport $record) {
133
                        $record->update([
134
                            'status' => 'dismissed',
135
                            'reviewed_by' => auth()->id(),
136
                            'reviewed_at' => now(),
137
                        ]);
138
                    }),
139
            ])
140
            ->toolbarActions([
141
                \Filament\Actions\BulkActionGroup::make([
0 ignored issues
show
Bug introduced by
The type Filament\Actions\BulkActionGroup was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
142
                    \Filament\Actions\BulkAction::make('mark_reviewed')
0 ignored issues
show
Bug introduced by
The type Filament\Actions\BulkAction was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
143
                        ->label('Mark as Reviewed')
144
                        ->icon('heroicon-o-check-circle')
145
                        ->color('success')
146
                        ->requiresConfirmation()
147
                        ->action(function ($records) {
148
                            $records->each(function (CommentReport $record) {
149
                                $record->update([
150
                                    'status' => 'reviewed',
151
                                    'reviewed_by' => auth()->id(),
152
                                    'reviewed_at' => now(),
153
                                ]);
154
                            });
155
                        }),
156
                    \Filament\Actions\DeleteBulkAction::make(),
0 ignored issues
show
Bug introduced by
The type Filament\Actions\DeleteBulkAction was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
157
                ]),
158
            ])
159
            ->defaultSort('created_at', 'desc');
160
    }
161
}
162
163