|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace App\Filament\Resources\Threads\Tables; |
| 4 | + |
| 5 | +use App\Models\Thread; |
| 6 | +use Filament\Actions\BulkActionGroup; |
| 7 | +use Filament\Actions\DeleteBulkAction; |
| 8 | +use Filament\Actions\Action; |
| 9 | +use Filament\Tables\Columns\TextColumn; |
| 10 | +use Filament\Tables\Columns\ImageColumn; |
| 11 | +use Filament\Tables\Table; |
| 12 | + |
| 13 | +class ThreadsTable |
| 14 | +{ |
| 15 | + public static function configure(Table $table): Table |
| 16 | + { |
| 17 | + return $table |
| 18 | + ->columns([ |
| 19 | + ImageColumn::make('authorRelation.github_id') |
| 20 | + ->label('Author') |
| 21 | + ->circular() |
| 22 | + ->defaultImageUrl(fn(?string $state): string => $state ? sprintf('https://avatars.githubusercontent.com/u/%s', $state) : asset('images/laravelio-icon-gray.svg')), |
| 23 | + |
| 24 | + TextColumn::make('authorRelation.name') |
| 25 | + ->label('') |
| 26 | + ->description(fn(Thread $thread): ?string => $thread->authorRelation->username) |
| 27 | + ->searchable(), |
| 28 | + |
| 29 | + TextColumn::make('subject') |
| 30 | + ->searchable(), |
| 31 | + |
| 32 | + TextColumn::make('solutionReplyRelation.body') |
| 33 | + ->label('Solution') |
| 34 | + ->limit(300) |
| 35 | + ->wrap() |
| 36 | + ->searchable(), |
| 37 | + |
| 38 | + |
| 39 | + ImageColumn::make('resolvedByRelation.github_id') |
| 40 | + ->label('Resolved by') |
| 41 | + ->circular() |
| 42 | + ->defaultImageUrl(fn(?string $state): string => $state ? sprintf('https://avatars.githubusercontent.com/u/%s', $state) : asset('images/laravelio-icon-gray.svg')), |
| 43 | + |
| 44 | + TextColumn::make('resolvedByRelation.name') |
| 45 | + ->label('') |
| 46 | + ->sortable() |
| 47 | + ->searchable(), |
| 48 | + |
| 49 | + |
| 50 | + ImageColumn::make('updatedByRelation.github_id') |
| 51 | + ->label('Updated by') |
| 52 | + ->circular() |
| 53 | + ->defaultImageUrl(fn(?string $state): string => $state ? sprintf('https://avatars.githubusercontent.com/u/%s', $state) : asset('images/laravelio-icon-gray.svg')), |
| 54 | + |
| 55 | + TextColumn::make('updatedByRelation.name') |
| 56 | + ->label('') |
| 57 | + ->sortable() |
| 58 | + ->searchable(), |
| 59 | + |
| 60 | + ImageColumn::make('lockedByRelation.github_id') |
| 61 | + ->label('Locked by') |
| 62 | + ->circular() |
| 63 | + ->defaultImageUrl(fn(?string $state): string => $state ? sprintf('https://avatars.githubusercontent.com/u/%s', $state) : asset('images/laravelio-icon-gray.svg')), |
| 64 | + |
| 65 | + TextColumn::make('lockedByRelation.name') |
| 66 | + ->label('') |
| 67 | + ->sortable() |
| 68 | + ->searchable(), |
| 69 | + |
| 70 | + TextColumn::make('last_activity_at') |
| 71 | + ->dateTime() |
| 72 | + ->sortable(), |
| 73 | + |
| 74 | + TextColumn::make('locked_at') |
| 75 | + ->dateTime() |
| 76 | + ->sortable(), |
| 77 | + |
| 78 | + TextColumn::make('created_at') |
| 79 | + ->dateTime() |
| 80 | + ->sortable() |
| 81 | + ->toggleable(isToggledHiddenByDefault: true), |
| 82 | + |
| 83 | + TextColumn::make('updated_at') |
| 84 | + ->dateTime() |
| 85 | + ->sortable() |
| 86 | + ->toggleable(isToggledHiddenByDefault: true), |
| 87 | + ]) |
| 88 | + ->recordActions([ |
| 89 | + Action::make('view') |
| 90 | + ->url(fn(Thread $thread): string => route('thread', $thread->slug())) |
| 91 | + ->openUrlInNewTab() |
| 92 | + ->icon('heroicon-s-eye'), |
| 93 | + |
| 94 | + ]) |
| 95 | + ->toolbarActions([ |
| 96 | + BulkActionGroup::make([ |
| 97 | + DeleteBulkAction::make(), |
| 98 | + ]), |
| 99 | + ]); |
| 100 | + } |
| 101 | +} |
0 commit comments