RepliesRelationManager::table()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 56
Code Lines 44

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 44
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 56
rs 9.216

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace Usamamuneerchaudhary\Commentify\Filament\Resources\CommentResource\RelationManagers;
4
5
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...
6
use Filament\Actions\DeleteAction;
0 ignored issues
show
Bug introduced by
The type Filament\Actions\DeleteAction 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\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...
8
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...
9
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...
10
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...
11
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...
12
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...
13
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...
14
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...
15
use Usamamuneerchaudhary\Commentify\Models\Comment;
16
17
class RepliesRelationManager extends RelationManager
18
{
19
    protected static string $relationship = 'children';
20
21
    protected static ?string $title = 'Replies';
22
23
    protected static ?string $recordTitleAttribute = 'id';
24
25
    public function form(Schema $schema): Schema
26
    {
27
        return $schema
28
            ->schema([
29
                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...
30
                    ->relationship('user', 'name')
31
                    ->searchable()
32
                    ->required()
33
                    ->disabled(),
34
                Forms\Components\Textarea::make('body')
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...
35
                    ->required()
36
                    ->maxLength(5000)
37
                    ->rows(4)
38
                    ->columnSpanFull()
39
                    ->helperText('Supports Markdown formatting'),
40
            ]);
41
    }
42
43
    public function table(Table $table): Table
44
    {
45
        return $table
46
            ->modifyQueryUsing(function ($query) {
47
                return $query->withCount(['likes', 'reports']);
48
            })
49
            ->recordTitleAttribute('id')
50
            ->columns([
51
                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...
52
                    ->label('ID')
53
                    ->sortable(),
54
                Tables\Columns\TextColumn::make('user.name')
55
                    ->label('User')
56
                    ->sortable()
57
                    ->searchable(),
58
                Tables\Columns\TextColumn::make('body')
59
                    ->label('Reply')
60
                    ->limit(100)
61
                    ->wrap()
62
                    ->searchable()
63
                    ->formatStateUsing(function (Comment $record) {
64
                        return strip_tags($record->presenter()->markdownBody());
65
                    }),
66
                Tables\Columns\TextColumn::make('likes_count')
67
                    ->label('Likes')
68
                    ->sortable()
69
                    ->badge()
70
                    ->color('success')
71
                    ->default(0),
72
                Tables\Columns\TextColumn::make('reports_count')
73
                    ->label('Reports')
74
                    ->sortable()
75
                    ->badge()
76
                    ->color(fn ($state) => ($state ?? 0) > 0 ? 'danger' : 'gray')
77
                    ->default(0),
78
                Tables\Columns\TextColumn::make('created_at')
79
                    ->dateTime()
80
                    ->sortable(),
81
            ])
82
            ->filters([
83
                //
84
            ])
85
            ->headerActions([
86
                // Tables\Actions\CreateAction::make(),
87
            ])
88
            ->recordActions([
89
                ViewAction::make(),
90
                EditAction::make(),
91
                DeleteAction::make(),
92
            ])
93
            ->toolbarActions([
94
                BulkActionGroup::make([
95
                    DeleteBulkAction::make(),
96
                ]),
97
            ])
98
            ->defaultSort('created_at', 'asc');
99
    }
100
}
101
102