<?php

namespace App\Filament\Resources\BiddersResource\RelationManagers;

use Filament\Forms;
use Filament\Schemas\Schema;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Tables\Table;
use Filament\Tables;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Actions\EditAction;
use Filament\Actions\CreateAction;
use Filament\Actions\DeleteAction;
use Filament\Actions\BulkActionGroup;
use Filament\Actions\DeleteBulkAction;
use Filament\Tables\Columns\TextColumn;

class CheckoutRelationManager extends RelationManager
{
    protected static string $relationship = 'checkout';

    protected static ?string $recordTitleAttribute = 'bidder_num';

    public function form(Schema $schema): Schema
    {
        return $schema
            ->components([
                Forms\Components\TextInput::make('bidder_num')
                    ->required()
                    ->maxLength(255),
            ]);
    }

    public function table(Table $table): Table
    {
        return $table
            ->columns([
                TextColumn::make('bidders.bidder_assigned_number')
                    ->label('Bidder Number')
                    ->sortable(),
                TextColumn::make('winnertotal')
                    ->label('Total Amount')
                    ->money('USD')
                    ->sortable(),
                TextColumn::make('paymentMethod.pm_name')
                    ->label('Payment Method')
                    ->sortable(),                
            ])
            ->filters([
                //
            ])
            ->recordActions([
                EditAction::make(),
                DeleteAction::make(),
            ])
            ->toolbarActions([
                CreateAction::make(),
                BulkActionGroup::make([
                    DeleteBulkAction::make(),
                ]),
            ]);
    }    
}
