38 lines
1.5 KiB
PHP
38 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Widgets;
|
|
|
|
use App\Enums\ShipmentStatus;
|
|
use App\Models\Shipment;
|
|
use Filament\Widgets\StatsOverviewWidget as BaseWidget;
|
|
use Filament\Widgets\StatsOverviewWidget\Stat;
|
|
|
|
/**
|
|
* ویجت سفارشهای در انتظار تأیید — مدیر را از سفارشهای جدید مطلع میکند.
|
|
*/
|
|
class PendingOrdersWidget extends BaseWidget
|
|
{
|
|
protected static ?int $sort = 3;
|
|
protected static bool $isLazy = false;
|
|
|
|
protected int | string | array $columnSpan = 'full';
|
|
|
|
protected function getStats(): array
|
|
{
|
|
$pendingCount = Shipment::where('status', ShipmentStatus::PendingApproval)->count();
|
|
$approvedUnpaidCount = Shipment::where('status', ShipmentStatus::Approved)->count();
|
|
|
|
return [
|
|
Stat::make('در انتظار تأیید', $pendingCount)
|
|
->description($pendingCount > 0 ? 'سفارش جدید منتظر بررسی' : 'سفارش جدیدی نیست')
|
|
->descriptionIcon('heroicon-m-clock')
|
|
->color($pendingCount > 0 ? 'warning' : 'gray')
|
|
->url($pendingCount > 0 ? '/panel/shipments' : null),
|
|
|
|
Stat::make('در انتظار پرداخت', $approvedUnpaidCount)
|
|
->description('سفارشهای تأییدشده — آماده پرداخت')
|
|
->descriptionIcon('heroicon-m-banknotes')
|
|
->color($approvedUnpaidCount > 0 ? 'info' : 'gray'),
|
|
];
|
|
}
|
|
} |