66 lines
2.5 KiB
PHP
66 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\WalletTransactions\Tables;
|
|
|
|
use App\Enums\WalletTransactionType;
|
|
use Filament\Actions\ViewAction;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Tables\Filters\SelectFilter;
|
|
use Filament\Tables\Table;
|
|
|
|
class WalletTransactionsTable
|
|
{
|
|
public static function configure(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
TextColumn::make('id')
|
|
->label('#')
|
|
->sortable(),
|
|
TextColumn::make('wallet.user.name')
|
|
->label('کاربر')
|
|
->searchable()
|
|
->sortable(),
|
|
TextColumn::make('wallet.user.mobile')
|
|
->label('موبایل')
|
|
->searchable()
|
|
->toggleable(),
|
|
TextColumn::make('type')
|
|
->label('نوع')
|
|
->badge()
|
|
->formatStateUsing(fn (WalletTransactionType $state): string => $state->label())
|
|
->color(fn (WalletTransactionType $state): string => $state === WalletTransactionType::Credit ? 'success' : 'danger'),
|
|
TextColumn::make('amount')
|
|
->label('مبلغ')
|
|
->sortable()
|
|
->formatStateUsing(fn (int $state): string => number_format($state).' تومان'),
|
|
TextColumn::make('balance_after')
|
|
->label('موجودی بعد')
|
|
->formatStateUsing(fn (int $state): string => number_format($state).' تومان'),
|
|
TextColumn::make('description')
|
|
->label('توضیحات')
|
|
->limit(50)
|
|
->searchable(),
|
|
TextColumn::make('creator.name')
|
|
->label('ثبتکننده')
|
|
->placeholder('سیستم'),
|
|
TextColumn::make('created_at')
|
|
->label('تاریخ')
|
|
->dateTime()
|
|
->sortable(),
|
|
])
|
|
->defaultSort('created_at', 'desc')
|
|
->filters([
|
|
SelectFilter::make('type')
|
|
->label('نوع')
|
|
->options([
|
|
WalletTransactionType::Credit->value => WalletTransactionType::Credit->label(),
|
|
WalletTransactionType::Debit->value => WalletTransactionType::Debit->label(),
|
|
]),
|
|
])
|
|
->recordActions([
|
|
ViewAction::make(),
|
|
]);
|
|
}
|
|
}
|