Implement a comprehensive financial management suite within the Filament admin panel, including new resources for payments and discount codes, along with a financial dashboard. - feat(ui): add Filament Dashboard with finance overview and transaction widgets - feat(ui): implement PaymentResource for monitoring gateway transactions - feat(ui): complete DiscountCodeResource with full CRUD and filtering - feat(wallet): add automatic wallet creation on balance retrieval - fix(wallet): resolve null handling in isFrozen() and balance viewing - fix(db): correct enum type from 'percent' to 'percentage' in discount_codes migration - fix(api): update pricing calculation endpoint to /api/v1/calculate - test: add 21 new feature and service tests covering wallet, payment, and discount logic - chore: remove obsolete PaymentGatewayService and update project status
70 lines
2.8 KiB
PHP
70 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Widgets;
|
|
|
|
use App\Models\WalletTransaction;
|
|
use Filament\Tables;
|
|
use Filament\Tables\Table;
|
|
use Filament\Widgets\TableWidget as BaseWidget;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
|
|
class RecentTransactionsWidget extends BaseWidget
|
|
{
|
|
protected static ?string $pollingInterval = '30s';
|
|
protected static ?string $heading = 'آخرین تراکنشها';
|
|
protected static ?int $sort = 2;
|
|
|
|
public function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->query(
|
|
WalletTransaction::query()
|
|
->latest()
|
|
->limit(10)
|
|
)
|
|
->columns([
|
|
Tables\Columns\TextColumn::make('id')
|
|
->label('ID')
|
|
->sortable()
|
|
->width(60),
|
|
Tables\Columns\TextColumn::make('wallet.user.name')
|
|
->label('کاربر')
|
|
->searchable()
|
|
->limit(20),
|
|
Tables\Columns\TextColumn::make('amount')
|
|
->label('مبلغ')
|
|
->money('IRR', divideBy: 1)
|
|
->color(fn ($record) => $record->amount >= 0 ? 'success' : 'danger')
|
|
->sortable(),
|
|
Tables\Columns\BadgeColumn::make('type')
|
|
->label('نوع')
|
|
->getStateUsing(fn ($record) => $record->type->label())
|
|
->colors([
|
|
'success' => \App\Enums\TransactionType::DEPOSIT,
|
|
'danger' => \App\Enums\TransactionType::WITHDRAWAL,
|
|
'warning' => \App\Enums\TransactionType::ORDER_PAYMENT,
|
|
'info' => \App\Enums\TransactionType::REFUND,
|
|
]),
|
|
Tables\Columns\BadgeColumn::make('status')
|
|
->label('وضعیت')
|
|
->getStateUsing(fn ($record) => $record->status->label())
|
|
->colors([
|
|
'success' => \App\Enums\TransactionStatus::COMPLETED,
|
|
'warning' => \App\Enums\TransactionStatus::PENDING,
|
|
'danger' => \App\Enums\TransactionStatus::FAILED,
|
|
'info' => \App\Enums\TransactionStatus::REFUNDED,
|
|
]),
|
|
Tables\Columns\TextColumn::make('gateway_reference_id')
|
|
->label('کد پیگیری')
|
|
->searchable()
|
|
->toggleable(),
|
|
Tables\Columns\TextColumn::make('created_at')
|
|
->label('تاریخ')
|
|
->dateTime('Y/m/d H:i', 'Asia/Tehran')
|
|
->sortable()
|
|
->since(),
|
|
])
|
|
->defaultSort('created_at', 'desc');
|
|
}
|
|
}
|