Files
minicrm/app/Filament/Resources/Feedback/Tables/FeedbackTable.php
phuongtc 8c6b71cb8a
Some checks failed
Tests / PHP 8.3 (push) Has been cancelled
Tests / PHP 8.4 (push) Has been cancelled
Tests / PHP 8.5 (push) Has been cancelled
feat: add i18n support for Vietnamese and English
2026-05-04 10:40:39 +00:00

125 lines
4.4 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('id')
->label('#')
->sortable()
->weight('bold')
->color('primary'),
TextColumn::make('title')
->searchable()
->sortable()
->weight('semibold')
->limit(40),
TextColumn::make('customer.name')
->searchable()
->sortable(),
TextColumn::make('customerProduct.product.name')
->label(__('app.product'))
->placeholder(__('app.general'))
->sortable()
->toggleable(),
TextColumn::make('contract.type')
->label(__('app.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(__('app.channel'))
->badge()
->color('gray'),
TextColumn::make('tags.name')
->badge()
->separator(',')
->toggleable(),
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(__('app.department'))
->badge()
->color('info')
->toggleable(),
TextColumn::make('assignedTo.name')
->label(__('app.assigned_to'))
->toggleable(),
IconColumn::make('is_escalated')
->label(__('app.escalated'))
->boolean()
->toggleable(),
TextColumn::make('created_at')
->label(__('app.created'))
->since()
->sortable()
->toggleable()
->color('secondary'),
])
->filters([
SelectFilter::make('status')
->options([
'pending' => __('app.status_pending'),
'processing' => __('app.status_processing'),
'resolved' => __('app.status_resolved'),
'closed' => __('app.status_closed'),
]),
SelectFilter::make('feedback_channel_id')
->relationship('feedbackChannel', 'name')
->label(__('app.channel')),
SelectFilter::make('current_department_id')
->relationship('currentDepartment', 'name')
->label(__('app.department')),
SelectFilter::make('assigned_to')
->relationship('assignedTo', 'name')
->label(__('app.assigned_to')),
])
->recordActions([
EditAction::make(),
])
->toolbarActions([
BulkActionGroup::make([
DeleteBulkAction::make(),
]),
])
->defaultSort('created_at', 'desc');
}
}