92 lines
3.6 KiB
PHP
92 lines
3.6 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\Contracts\Tables;
|
|
|
|
use App\Enums\ContractCategory;
|
|
use Filament\Actions\BulkActionGroup;
|
|
use Filament\Actions\DeleteBulkAction;
|
|
use Filament\Actions\EditAction;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Tables\Filters\SelectFilter;
|
|
use Filament\Tables\Table;
|
|
|
|
class ContractsTable
|
|
{
|
|
public static function configure(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
TextColumn::make('id')
|
|
->sortable(),
|
|
TextColumn::make('product.name')
|
|
->label(__('app.product'))
|
|
->searchable()
|
|
->sortable(),
|
|
TextColumn::make('customer.name')
|
|
->label(__('app.widget_customer'))
|
|
->searchable()
|
|
->sortable(),
|
|
TextColumn::make('category')
|
|
->label(__('enums.contract_category_label'))
|
|
->badge()
|
|
->formatStateUsing(fn (string $state): string => ContractCategory::from($state)->label())
|
|
->color(fn (string $state): string => ContractCategory::from($state)->color()),
|
|
TextColumn::make('type')
|
|
->label(__('enums.contract_type_label'))
|
|
->badge()
|
|
->formatStateUsing(fn (string $state): string => \App\Enums\ContractType::from($state)->label())
|
|
->color(fn (string $state): string => \App\Enums\ContractType::from($state)->color()),
|
|
TextColumn::make('status')
|
|
->label(__('app.status'))
|
|
->badge()
|
|
->color(fn (string $state): string => match ($state) {
|
|
'active' => 'success',
|
|
'expired' => 'warning',
|
|
'liquidated' => 'danger',
|
|
default => 'gray',
|
|
})
|
|
->formatStateUsing(fn (string $state): string => \App\Enums\ContractStatus::from($state)->label()),
|
|
TextColumn::make('representative_name')
|
|
->label(__('app.representative'))
|
|
->placeholder('-')
|
|
->toggleable(),
|
|
TextColumn::make('start_date')
|
|
->label(__('app.start_date'))
|
|
->date()
|
|
->sortable()
|
|
->toggleable(),
|
|
TextColumn::make('end_date')
|
|
->label(__('app.end_date'))
|
|
->date()
|
|
->sortable()
|
|
->toggleable(),
|
|
TextColumn::make('signed_status')
|
|
->label(__('app.signed_status'))
|
|
->toggleable(),
|
|
TextColumn::make('feedbacks_count')
|
|
->counts('feedbacks')
|
|
->label(__('app.tickets')),
|
|
TextColumn::make('created_at')
|
|
->dateTime()
|
|
->sortable()
|
|
->toggleable(),
|
|
])
|
|
->filters([
|
|
SelectFilter::make('category')
|
|
->label(__('enums.contract_category_label'))
|
|
->options(ContractCategory::options()),
|
|
SelectFilter::make('status')
|
|
->label(__('app.status'))
|
|
->options(\App\Enums\ContractStatus::ACTIVE->options()),
|
|
])
|
|
->recordActions([
|
|
EditAction::make(),
|
|
])
|
|
->toolbarActions([
|
|
BulkActionGroup::make([
|
|
DeleteBulkAction::make(),
|
|
]),
|
|
]);
|
|
}
|
|
}
|