|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Usamamuneerchaudhary\Commentify\Filament\Resources\CommentResource\RelationManagers; |
|
4
|
|
|
|
|
5
|
|
|
use Filament\Actions\BulkActionGroup; |
|
|
|
|
|
|
6
|
|
|
use Filament\Actions\DeleteAction; |
|
|
|
|
|
|
7
|
|
|
use Filament\Actions\DeleteBulkAction; |
|
|
|
|
|
|
8
|
|
|
use Filament\Actions\EditAction; |
|
|
|
|
|
|
9
|
|
|
use Filament\Actions\ViewAction; |
|
|
|
|
|
|
10
|
|
|
use Filament\Forms; |
|
|
|
|
|
|
11
|
|
|
use Filament\Resources\RelationManagers\RelationManager; |
|
|
|
|
|
|
12
|
|
|
use Filament\Schemas\Schema; |
|
|
|
|
|
|
13
|
|
|
use Filament\Tables; |
|
|
|
|
|
|
14
|
|
|
use Filament\Tables\Table; |
|
|
|
|
|
|
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') |
|
|
|
|
|
|
30
|
|
|
->relationship('user', 'name') |
|
31
|
|
|
->searchable() |
|
32
|
|
|
->required() |
|
33
|
|
|
->disabled(), |
|
34
|
|
|
Forms\Components\Textarea::make('body') |
|
|
|
|
|
|
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') |
|
|
|
|
|
|
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
|
|
|
|
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