78 lines
2.6 KiB
PHP
78 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\Customers\Tables;
|
|
|
|
use Filament\Actions\BulkActionGroup;
|
|
use Filament\Actions\DeleteBulkAction;
|
|
use Filament\Actions\EditAction;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Tables\Columns\IconColumn;
|
|
use Filament\Tables\Table;
|
|
|
|
class CustomersTable
|
|
{
|
|
public static function configure(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
TextColumn::make('full_name')
|
|
->label('Họ tên / Công ty')
|
|
->searchable()
|
|
->sortable()
|
|
->description(fn ($record) => $get_desc = $record->type === 'COMPANY' ? "ĐD: {$record->representative?->full_name}" : $record->cmnd_cccd),
|
|
|
|
TextColumn::make('type')
|
|
->label('Loại')
|
|
->badge()
|
|
->color(fn (string $state): string => match ($state) {
|
|
'COMPANY' => 'warning',
|
|
'INDIVIDUAL' => 'success',
|
|
default => 'gray',
|
|
})
|
|
->formatStateUsing(fn (string $state): string => match ($state) {
|
|
'COMPANY' => 'Công ty',
|
|
'INDIVIDUAL' => 'Cá nhân',
|
|
default => $state,
|
|
}),
|
|
|
|
TextColumn::make('phone')
|
|
->label('Điện thoại')
|
|
->searchable(),
|
|
|
|
TextColumn::make('permanent_address')
|
|
->label('Địa chỉ thường trú')
|
|
->limit(30)
|
|
->searchable()
|
|
->toggleable(),
|
|
|
|
TextColumn::make('contact_address')
|
|
->label('Địa chỉ liên hệ')
|
|
->limit(30)
|
|
->searchable()
|
|
->toggleable(),
|
|
|
|
TextColumn::make('created_at')
|
|
->label('Ngày tạo')
|
|
->dateTime('d/m/Y')
|
|
->sortable()
|
|
->toggleable(isToggledHiddenByDefault: true),
|
|
])
|
|
->filters([
|
|
\Filament\Tables\Filters\SelectFilter::make('type')
|
|
->label('Loại khách hàng')
|
|
->options([
|
|
'INDIVIDUAL' => 'Cá nhân',
|
|
'COMPANY' => 'Công ty',
|
|
]),
|
|
])
|
|
->recordActions([
|
|
EditAction::make(),
|
|
])
|
|
->bulkActions([
|
|
BulkActionGroup::make([
|
|
DeleteBulkAction::make(),
|
|
]),
|
|
]);
|
|
}
|
|
}
|