78 lines
3.0 KiB
PHP
78 lines
3.0 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\TenantFeedbackResource\Tables;
|
|
|
|
use App\Models\TenantFeedback;
|
|
use Filament\Actions\ViewAction;
|
|
use Filament\Tables;
|
|
use Filament\Tables\Filters\SelectFilter;
|
|
use Filament\Tables\Table;
|
|
use Illuminate\Support\Str;
|
|
|
|
class TenantFeedbackTable
|
|
{
|
|
public static function configure(Table $table): Table
|
|
{
|
|
return $table
|
|
->defaultSort('created_at', 'desc')
|
|
->columns([
|
|
Tables\Columns\TextColumn::make('created_at')
|
|
->label(__('Eingegangen'))
|
|
->since()
|
|
->sortable(),
|
|
Tables\Columns\TextColumn::make('tenant.name')
|
|
->label(__('Tenant'))
|
|
->searchable()
|
|
->limit(30),
|
|
Tables\Columns\TextColumn::make('event.name')
|
|
->label(__('Event'))
|
|
->limit(30)
|
|
->toggleable(),
|
|
Tables\Columns\TextColumn::make('category')
|
|
->label(__('Kategorie'))
|
|
->badge()
|
|
->formatStateUsing(fn (string $state) => Str::headline($state))
|
|
->sortable(),
|
|
Tables\Columns\TextColumn::make('sentiment')
|
|
->label(__('Stimmung'))
|
|
->badge()
|
|
->color(fn (?string $state) => match ($state) {
|
|
'positive' => 'success',
|
|
'neutral' => 'warning',
|
|
'negative' => 'danger',
|
|
default => 'gray',
|
|
})
|
|
->formatStateUsing(fn (?string $state) => $state ? Str::headline($state) : '—')
|
|
->sortable(),
|
|
Tables\Columns\TextColumn::make('rating')
|
|
->label(__('Rating'))
|
|
->formatStateUsing(fn (?int $state) => $state ? sprintf('%d/5', $state) : '—')
|
|
->sortable(),
|
|
Tables\Columns\TextColumn::make('message')
|
|
->label(__('Nachricht'))
|
|
->limit(60)
|
|
->toggleable(isToggledHiddenByDefault: true),
|
|
])
|
|
->filters([
|
|
SelectFilter::make('sentiment')
|
|
->label(__('Stimmung'))
|
|
->options([
|
|
'positive' => __('Positiv'),
|
|
'neutral' => __('Neutral'),
|
|
'negative' => __('Negativ'),
|
|
]),
|
|
SelectFilter::make('category')
|
|
->label(__('Kategorie'))
|
|
->options(fn () => TenantFeedback::query()
|
|
->whereNotNull('category')
|
|
->orderBy('category')
|
|
->pluck('category', 'category')
|
|
->toArray()),
|
|
])
|
|
->recordActions([
|
|
ViewAction::make(),
|
|
])
|
|
->bulkActions([]);
|
|
}
|
|
}
|