<?php

namespace App\Filament\Tenant\Resources\OnlineOrderResource\RelationManagers;

use Filament\Resources\RelationManagers\RelationManager;
use Filament\Tables;
use Filament\Tables\Table;

class ItemsRelationManager extends RelationManager
{
    protected static string $relationship = 'items';

    protected static ?string $title = null;

    public static function getTitle(\Illuminate\Database\Eloquent\Model $ownerRecord, string $pageClass): string
    {
        return __('Produse');
    }

    public function table(Table $table): Table
    {
        return $table
            ->recordTitleAttribute('name')
            ->columns([
                Tables\Columns\TextColumn::make('name')->label(__('Piesă'))->wrap(),
                Tables\Columns\TextColumn::make('article')->label(__('Cod'))->placeholder('—'),
                Tables\Columns\TextColumn::make('qty')->label(__('Cant.'))->alignRight(),
                Tables\Columns\TextColumn::make('price')->label(__('Preț'))->money('MDL')->alignRight(),
                Tables\Columns\TextColumn::make('total')->money('MDL')->alignRight(),
                Tables\Columns\IconColumn::make('fulfilled')->label(__('Onorat'))->boolean(),
            ]);
    }
}
