CommentReportResource   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 165
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 128
c 1
b 0
f 1
dl 0
loc 165
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getRelations() 0 3 1
B table() 0 100 1
A form() 0 36 1
A getPages() 0 7 1
1
<?php
2
3
namespace Usamamuneerchaudhary\Commentify\Filament\Resources;
4
5
use Filament\Actions\Action;
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...
6
use Filament\Actions\BulkAction;
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...
7
use Filament\Actions\BulkActionGroup;
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...
8
use Filament\Actions\DeleteBulkAction;
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...
9
use Filament\Actions\EditAction;
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...
10
use Filament\Actions\ViewAction;
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...
11
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...
12
use Filament\Forms\Form;
0 ignored issues
show
Bug introduced by
The type Filament\Forms\Form 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...
13
use Filament\Resources\Resource;
0 ignored issues
show
Bug introduced by
The type Filament\Resources\Resource 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...
14
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...
15
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...
16
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...
17
use Usamamuneerchaudhary\Commentify\Filament\Resources\CommentReportResource\Pages;
18
use Usamamuneerchaudhary\Commentify\Models\CommentReport;
19
20
class CommentReportResource extends Resource
21
{
22
    protected static ?string $model = CommentReport::class;
23
24
    protected static string|null|\BackedEnum $navigationIcon = 'heroicon-o-flag';
0 ignored issues
show
Bug introduced by
The type BackedEnum 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
26
    protected static string|null|\UnitEnum $navigationGroup = 'Commentify';
0 ignored issues
show
Bug introduced by
The type UnitEnum 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...
27
28
    protected static ?int $navigationSort = 1;
29
30
    public static function form(Schema $schema): Schema
31
    {
32
        return $schema
33
            ->schema([
34
                Forms\Components\Select::make('comment_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...
35
                    ->relationship('comment', 'id')
36
                    ->searchable()
37
                    ->required()
38
                    ->disabled(),
39
                Forms\Components\Select::make('user_id')
40
                    ->relationship('user', 'name')
41
                    ->searchable()
42
                    ->nullable(),
43
                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...
44
                    ->label('IP Address')
45
                    ->disabled(),
46
                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...
47
                    ->required()
48
                    ->maxLength(1000)
49
                    ->rows(4)
50
                    ->columnSpanFull(),
51
                Forms\Components\Select::make('status')
52
                    ->options([
53
                        'pending' => 'Pending',
54
                        'reviewed' => 'Reviewed',
55
                        'dismissed' => 'Dismissed',
56
                    ])
57
                    ->required()
58
                    ->default('pending'),
59
                Forms\Components\Select::make('reviewed_by')
60
                    ->relationship('reviewer', 'name')
61
                    ->searchable()
62
                    ->nullable()
63
                    ->visible(fn ($get) => $get('status') !== 'pending'),
64
                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...
65
                    ->visible(fn ($get) => $get('status') !== 'pending'),
66
            ]);
67
    }
68
69
    public static function table(Table $table): Table
70
    {
71
        return $table
72
            ->columns([
73
                Tables\Columns\TextColumn::make('comment.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...
74
                    ->label('Comment ID')
75
                    ->sortable()
76
                    ->searchable(),
77
                Tables\Columns\TextColumn::make('user.name')
78
                    ->label('Reporter')
79
                    ->sortable()
80
                    ->searchable()
81
                    ->default('Guest'),
82
                Tables\Columns\TextColumn::make('ip')
83
                    ->label('IP Address')
84
                    ->searchable()
85
                    ->toggleable(),
86
                Tables\Columns\TextColumn::make('reason')
87
                    ->limit(50)
88
                    ->wrap()
89
                    ->searchable(),
90
                Tables\Columns\TextColumn::make('status')
91
                    ->badge()
92
                    ->color(fn (string $state): string => match ($state) {
93
                        'pending' => 'warning',
94
                        'reviewed' => 'success',
95
                        'dismissed' => 'danger',
96
                        default => 'gray',
97
                    }),
98
                Tables\Columns\TextColumn::make('reviewer.name')
99
                    ->label('Reviewed By')
100
                    ->sortable()
101
                    ->toggleable(),
102
                Tables\Columns\TextColumn::make('reviewed_at')
103
                    ->dateTime()
104
                    ->sortable()
105
                    ->toggleable(),
106
                Tables\Columns\TextColumn::make('created_at')
107
                    ->dateTime()
108
                    ->sortable()
109
                    ->toggleable(isToggledHiddenByDefault: true),
110
            ])
111
            ->filters([
112
                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...
113
                    ->options([
114
                        'pending' => 'Pending',
115
                        'reviewed' => 'Reviewed',
116
                        'dismissed' => 'Dismissed',
117
                    ]),
118
            ])
119
            ->recordActions([
120
                Action::make('review')
121
                    ->label('Mark as Reviewed')
122
                    ->icon('heroicon-o-check-circle')
123
                    ->color('success')
124
                    ->requiresConfirmation()
125
                    ->visible(fn (CommentReport $record) => $record->status === 'pending')
126
                    ->action(function (CommentReport $record) {
127
                        $record->update([
128
                            'status' => 'reviewed',
129
                            'reviewed_by' => auth()->id(),
130
                            'reviewed_at' => now(),
131
                        ]);
132
                    }),
133
                Action::make('dismiss')
134
                    ->label('Dismiss')
135
                    ->icon('heroicon-o-x-circle')
136
                    ->color('danger')
137
                    ->requiresConfirmation()
138
                    ->visible(fn (CommentReport $record) => $record->status === 'pending')
139
                    ->action(function (CommentReport $record) {
140
                        $record->update([
141
                            'status' => 'dismissed',
142
                            'reviewed_by' => auth()->id(),
143
                            'reviewed_at' => now(),
144
                        ]);
145
                    }),
146
                ViewAction::make(),
147
                EditAction::make(),
148
            ])
149
            ->toolbarActions([
150
                BulkActionGroup::make([
151
                    DeleteBulkAction::make(),
152
                    BulkAction::make('mark_reviewed')
153
                        ->label('Mark as Reviewed')
154
                        ->icon('heroicon-o-check-circle')
155
                        ->color('success')
156
                        ->requiresConfirmation()
157
                        ->action(function ($records) {
158
                            $records->each(function (CommentReport $record) {
159
                                $record->update([
160
                                    'status' => 'reviewed',
161
                                    'reviewed_by' => auth()->id(),
162
                                    'reviewed_at' => now(),
163
                                ]);
164
                            });
165
                        }),
166
                ]),
167
            ])
168
            ->defaultSort('created_at', 'desc');
169
    }
170
171
    public static function getRelations(): array
172
    {
173
        return [
174
            //
175
        ];
176
    }
177
178
    public static function getPages(): array
179
    {
180
        return [
181
            'index' => Pages\ListCommentReports::route('/'),
182
            'create' => Pages\CreateCommentReport::route('/create'),
183
            'view' => Pages\ViewCommentReport::route('/{record}'),
184
            'edit' => Pages\EditCommentReport::route('/{record}/edit'),
185
        ];
186
    }
187
}
188
189