<?php

namespace App\Filament\Widgets;

use App\Models\ConsultationRequest;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use Filament\Widgets\TableWidget;
use Illuminate\Database\Eloquent\Builder;

class RecentConsultationRequests extends TableWidget
{
    protected int|string|array $columnSpan = 'full';

    public function table(Table $table): Table
    {
        return $table
            ->heading('Recent consultation requests')
            ->query(fn (): Builder => ConsultationRequest::query()->latest())
            ->columns([
                TextColumn::make('name')->searchable()->sortable(),
                TextColumn::make('email')->searchable(),
                TextColumn::make('phone')->toggleable(),
                TextColumn::make('status')->badge(),
                TextColumn::make('preferred_date')->date()->sortable(),
                TextColumn::make('created_at')->since()->sortable(),
            ]);
    }
}
