feat: phase 6 — dashboard widgets, sales & stock reports, user management, activity log
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use App\Services\OrderService;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Widgets\TableWidget;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class RecentOrders extends TableWidget
|
||||
{
|
||||
protected static ?int $sort = 2;
|
||||
|
||||
protected int|string|array $columnSpan = 'full';
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
$service = app(OrderService::class);
|
||||
|
||||
return $table
|
||||
->heading('Pesanan Terbaru')
|
||||
->records(fn () => new Collection($service->recent(8)))
|
||||
->columns([
|
||||
TextColumn::make('order_number')->label('No. Order')->badge(),
|
||||
TextColumn::make('customers.name')->label('Pelanggan'),
|
||||
TextColumn::make('order_date')->label('Tgl')->date('d M Y'),
|
||||
TextColumn::make('order_status')
|
||||
->label('Status')
|
||||
->badge()
|
||||
->color(fn (string $state): string => match ($state) {
|
||||
'pending' => 'gray',
|
||||
'processing' => 'info',
|
||||
'delivering' => 'warning',
|
||||
'completed' => 'success',
|
||||
default => 'danger',
|
||||
})
|
||||
->formatStateUsing(fn (string $state): string => match ($state) {
|
||||
'pending' => 'Pending',
|
||||
'processing' => 'Diproses',
|
||||
'delivering' => 'Dikirim',
|
||||
'completed' => 'Selesai',
|
||||
default => 'Batal',
|
||||
}),
|
||||
])
|
||||
->paginated(false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user