ifnex/04_Laravel/app/Filament/Widgets/RecentTransactionsWidget.php
Kazem Alghasi 91984dbde3 feat(ui): redesign admin dashboard with layered grid and custom branding
Implement a comprehensive overhaul of the Filament admin dashboard,
introducing a structured 12-column responsive grid layout and enhanced
visual identity.

Key changes include:
- Redesigned Dashboard layout with a 4-layer progressive disclosure
  architecture (KPIs, Exchange Rates, Data Tables, and Trends).
- Introduced custom IFNEX design tokens via CSS, including branded
  stat cards, status badges, and improved sidebar typography.
- Enhanced FinanceOverviewWidget with real-time trend analysis and
  sparkline-ready data structures.
- Refactored RecentShipments and RecentTransactions widgets to use
  custom Blade templates for a more polished, consistent UI.
- Integrated brand assets including the company logo and custom
  authentication pages.
- Added global number formatting helpers and integrated them into
  financial widgets.
- Updated AdminPanelProvider to support custom login pages and
  brand-specific header/footer hooks.
2026-10-03 11:08:50 +03:30

73 lines
2.5 KiB
PHP

<?php
namespace App\Filament\Widgets;
use App\Enums\TransactionStatus;
use App\Enums\TransactionType;
use App\Models\WalletTransaction;
use Filament\Widgets\Widget;
use Morilog\Jalali\Jalalian;
/**
* Layer 3 (right) — recent transactions table, spanning 6/12 of the body grid.
* استایل و ساختار همسان با RecentShipmentsWidget (کارت + هدر آیکون‌دار + بج‌های برند).
*/
class RecentTransactionsWidget extends Widget
{
protected static ?int $sort = 7;
protected static bool $isLazy = false;
protected int|string|array $columnSpan = 6;
protected static string $view = 'filament.widgets.recent-transactions';
protected function getViewData(): array
{
$transactions = WalletTransaction::query()
->with('wallet.user')
->latest()
->limit(5)
->get()
->map(function ($t) {
return [
'user' => $t->wallet?->user?->name ?? '—',
'amount' => ifnex_format_number(abs((float) $t->amount)),
'amount_negative' => $t->amount < 0,
'type_label' => $t->type->label(),
'type_color' => $this->typeBadgeClass($t->type),
'status_label' => $t->status->label(),
'status_color' => $this->statusBadgeClass($t->status),
'date' => Jalalian::fromCarbon($t->created_at)->format('Y/m/d H:i'),
];
});
return [
'transactions' => $transactions,
'viewAllUrl' => route('filament.admin.resources.wallet-transactions.index'),
];
}
private function typeBadgeClass(TransactionType $type): string
{
return match ($type) {
TransactionType::DEPOSIT => 'ifnex-badge-success',
TransactionType::WITHDRAWAL => 'ifnex-badge-danger',
TransactionType::ORDER_PAYMENT => 'ifnex-badge-warning',
TransactionType::REFUND => 'ifnex-badge-info',
default => 'ifnex-badge-gray',
};
}
private function statusBadgeClass(TransactionStatus $status): string
{
return match ($status) {
TransactionStatus::COMPLETED => 'ifnex-badge-success',
TransactionStatus::PENDING => 'ifnex-badge-warning',
TransactionStatus::FAILED => 'ifnex-badge-danger',
TransactionStatus::REFUNDED => 'ifnex-badge-info',
default => 'ifnex-badge-gray',
};
}
}