<?php

namespace App\Filament\Widgets;

use App\Models\Order;
use Filament\Actions\BulkActionGroup;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Enums\PaginationMode;
use Filament\Tables\Table;
use Filament\Widgets\TableWidget;
use Illuminate\Database\Eloquent\Builder;

class LatestOrders extends TableWidget
{
    protected static ?int $sort = 4;

    public function table(Table $table): Table
    {
        return $table
            ->query(fn (): Builder => Order::query())
            ->defaultSort('id', 'desc')
            ->paginationMode(PaginationMode::Simple)
            ->defaultPaginationPageOption(5)
            ->columns([
                TextColumn::make('name')
                    ->description(fn ($record) => $record->email),
                TextColumn::make('amount')
                    ->money(fn ($record) => $record->currency),
                TextColumn::make('status')
                    ->badge(),
                TextColumn::make('created_at')
                    ->date(),
            ]);
    }
}
