| Conditions | 1 |
| Paths | 1 |
| Total Lines | 104 |
| Code Lines | 86 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
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:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 56 | public function table(Table $table): Table |
||
| 57 | { |
||
| 58 | return $table |
||
| 59 | ->recordTitleAttribute('id') |
||
| 60 | ->columns([ |
||
| 61 | Tables\Columns\TextColumn::make('id') |
||
| 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') |
||
| 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(), |
||
| 112 | \Filament\Actions\EditAction::make(), |
||
| 113 | \Filament\Actions\Action::make('review') |
||
| 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([ |
||
| 142 | \Filament\Actions\BulkAction::make('mark_reviewed') |
||
| 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(), |
||
| 157 | ]), |
||
| 158 | ]) |
||
| 159 | ->defaultSort('created_at', 'desc'); |
||
| 160 | } |
||
| 163 |
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