105 lines
4.1 KiB
PHP
105 lines
4.1 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\Feedback\Tables;
|
|
|
|
use Filament\Actions\BulkActionGroup;
|
|
use Filament\Actions\DeleteBulkAction;
|
|
use Filament\Actions\EditAction;
|
|
use Filament\Tables\Columns\IconColumn;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Tables\Filters\SelectFilter;
|
|
use Filament\Tables\Table;
|
|
|
|
class FeedbackTable
|
|
{
|
|
public static function configure(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
TextColumn::make('title')
|
|
->searchable()
|
|
->sortable(),
|
|
TextColumn::make('customer.name')
|
|
->searchable()
|
|
->sortable(),
|
|
TextColumn::make('customerProduct.product.name')
|
|
->label('Product')
|
|
->placeholder('General')
|
|
->sortable(),
|
|
TextColumn::make('contract.type')
|
|
->label('Contract')
|
|
->badge()
|
|
->formatStateUsing(fn (?string $state): string => $state ? \App\Enums\ContractType::from($state)->label() : '-')
|
|
->color(fn (?string $state): string => match ($state) {
|
|
'sale' => 'success',
|
|
'lease' => 'info',
|
|
'bcc' => 'warning',
|
|
default => 'gray',
|
|
})
|
|
->placeholder('-')
|
|
->toggleable(),
|
|
TextColumn::make('feedbackChannel.name')
|
|
->label('Channel')
|
|
->formatStateUsing(fn ($state, $record) => sprintf(
|
|
'<span style="display:inline-block;background:%s;color:#fff;padding:2px 10px;border-radius:9999px;font-size:0.75rem;">%s</span>',
|
|
$record->feedbackChannel?->color ?: '#6b7280',
|
|
e($state)
|
|
))
|
|
->html(),
|
|
TextColumn::make('tags.name')
|
|
->badge()
|
|
->separator(','),
|
|
TextColumn::make('status')
|
|
->badge()
|
|
->color(fn(string $state): string => match ($state) {
|
|
'pending' => 'warning',
|
|
'processing' => 'info',
|
|
'resolved' => 'success',
|
|
'closed' => 'gray',
|
|
default => 'gray',
|
|
}),
|
|
TextColumn::make('currentDepartment.name')
|
|
->label('Department')
|
|
->toggleable(),
|
|
TextColumn::make('assignedTo.name')
|
|
->label('Assigned To')
|
|
->toggleable(),
|
|
IconColumn::make('is_escalated')
|
|
->label('Escalated')
|
|
->boolean()
|
|
->toggleable(),
|
|
TextColumn::make('created_at')
|
|
->dateTime()
|
|
->sortable()
|
|
->toggleable(),
|
|
])
|
|
->filters([
|
|
SelectFilter::make('status')
|
|
->options([
|
|
'pending' => 'Pending',
|
|
'processing' => 'Processing',
|
|
'resolved' => 'Resolved',
|
|
'closed' => 'Closed',
|
|
]),
|
|
SelectFilter::make('feedback_channel_id')
|
|
->relationship('feedbackChannel', 'name')
|
|
->label('Channel'),
|
|
SelectFilter::make('current_department_id')
|
|
->relationship('currentDepartment', 'name')
|
|
->label('Department'),
|
|
SelectFilter::make('assigned_to')
|
|
->relationship('assignedTo', 'name')
|
|
->label('Assigned To'),
|
|
])
|
|
->recordActions([
|
|
EditAction::make(),
|
|
])
|
|
->toolbarActions([
|
|
BulkActionGroup::make([
|
|
DeleteBulkAction::make(),
|
|
]),
|
|
])
|
|
->defaultSort('created_at', 'desc');
|
|
}
|
|
}
|