<?php

namespace App\Filament\Resources\BiddersResource\RelationManagers;

use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Tables\Table;
use Filament\Tables;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;

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

    protected static ?string $recordTitleAttribute = 'bidder_num';

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

    public function table(Table $table): Table
    {
        return $table
            ->columns([
                Tables\Columns\TextColumn::make('bidders.bidder_assigned_number')
                    ->label('Bidder Number')
                    ->sortable(),
                Tables\Columns\TextColumn::make('winnertotal')
                    ->label('Total Amount')
                    ->money('usd', 'true')
                    ->sortable(),
                Tables\Columns\TextColumn::make('paymentMethod.pm_name')
                    ->label('Payment Method')
                    ->sortable(),                
            ])
            ->filters([
                //
            ])
            ->headerActions([
                Tables\Actions\CreateAction::make(),
            ])
            ->actions([
                Tables\Actions\EditAction::make(),
                Tables\Actions\DeleteAction::make(),
            ])
            ->bulkActions([
                Tables\Actions\BulkActionGroup::make([
                    Tables\Actions\DeleteBulkAction::make(),
                ]),
            ]);
    }    
}
