57 lines
1.9 KiB
PHP
57 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\FormTemplates\Tables;
|
|
|
|
use Filament\Tables;
|
|
use Filament\Tables\Table;
|
|
|
|
class FormTemplatesTable
|
|
{
|
|
public static function configure(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
Tables\Columns\TextColumn::make('name')
|
|
->label('Tên biểu mẫu')
|
|
->searchable()
|
|
->sortable(),
|
|
|
|
Tables\Columns\TextColumn::make('code')
|
|
->label('Mã')
|
|
->searchable()
|
|
->copyable(),
|
|
|
|
Tables\Columns\TextColumn::make('target_model')
|
|
->label('Áp dụng cho')
|
|
->formatStateUsing(fn ($state) => match ($state) {
|
|
'App\Models\Contract' => 'Hợp đồng',
|
|
'App\Models\Product' => 'Sản phẩm',
|
|
'App\Models\Customer' => 'Khách hàng',
|
|
default => $state,
|
|
}),
|
|
|
|
Tables\Columns\TextColumn::make('paper_size')
|
|
->label('Khổ giấy')
|
|
->badge(),
|
|
|
|
Tables\Columns\IconColumn::make('is_active')
|
|
->label('Hoạt động')
|
|
->boolean(),
|
|
|
|
Tables\Columns\TextColumn::make('fields_count')
|
|
->label('Số trường')
|
|
->counts('fields'),
|
|
])
|
|
->filters([
|
|
Tables\Filters\SelectFilter::make('target_model')
|
|
->label('Áp dụng cho')
|
|
->options([
|
|
'App\Models\Contract' => 'Hợp đồng',
|
|
'App\Models\Product' => 'Sản phẩm',
|
|
'App\Models\Customer' => 'Khách hàng',
|
|
]),
|
|
])
|
|
->defaultSort('name');
|
|
}
|
|
}
|