95aeecb932
- LowStockTable: rename getHeading → getTableHeading (correct Filament API) - Global I18n::opts() helper wraps Model::CONST values in __() so Select dropdowns show translated status/type/season/etc. labels - Sed-transform ->options(X::CONST), ->options(array_combine(X::A,X::A)), and formatStateUsing(fn($s)=>X::CONST[$s]??$s) → wrap with __() (58 options + 10 combines + 7 formatStateUsing across 28 files) - CalendarBoard: all 7 day names now via __() (was missing 4) - calendar-board.blade: fix untranslated 'săptămâna curentă', 'capacitate', 'rata confirmare', 'mediu', 'plin', 'Pod / Zi' / 'Mecanic / Zi' - +40 RU/EN translations (Client & Auto, Maistru / Mecanic, Programat, Sosit, Finalizat, Anulat, Neprezentat, days of week, calendar KPIs) All 306 tests pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
66 lines
2.5 KiB
PHP
66 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Tenant\Resources\WorkOrderResource\RelationManagers;
|
|
|
|
use App\Models\Tenant\Payment;
|
|
use Filament\Actions;
|
|
use Filament\Forms;
|
|
use Filament\Resources\RelationManagers\RelationManager;
|
|
use Filament\Schemas\Schema;
|
|
use Filament\Tables;
|
|
use Filament\Tables\Table;
|
|
|
|
class PaymentsRelationManager extends RelationManager
|
|
{
|
|
protected static string $relationship = 'payments';
|
|
|
|
protected static ?string $title = null;
|
|
|
|
public static function getTitle(\Illuminate\Database\Eloquent\Model $ownerRecord, string $pageClass): string
|
|
{
|
|
return __('Plăți');
|
|
}
|
|
|
|
public function form(Schema $schema): Schema
|
|
{
|
|
return $schema->components([
|
|
Forms\Components\DatePicker::make('paid_at')->label(__('Data'))->default(today())->required(),
|
|
Forms\Components\TextInput::make('amount')->label(__('Sumă'))->numeric()->required(),
|
|
Forms\Components\Select::make('method')
|
|
->options(\App\Support\I18n::opts(Payment::METHODS))
|
|
->default('cash')
|
|
->required(),
|
|
Forms\Components\TextInput::make('reference')->label(__('Referință'))->maxLength(64),
|
|
Forms\Components\Textarea::make('notes')->label(__('Notițe'))->columnSpanFull()->rows(2),
|
|
]);
|
|
}
|
|
|
|
public function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->recordTitleAttribute('amount')
|
|
->columns([
|
|
Tables\Columns\TextColumn::make('paid_at')->label(__('Data'))->date('d.m.Y'),
|
|
Tables\Columns\TextColumn::make('amount')->money('MDL')->alignRight()
|
|
->summarize(Tables\Columns\Summarizers\Sum::make()->money('MDL')->label(__('Plătit'))),
|
|
Tables\Columns\TextColumn::make('method')
|
|
->formatStateUsing(fn ($s) => Payment::METHODS[$s] ?? $s)
|
|
->badge(),
|
|
Tables\Columns\TextColumn::make('reference')->placeholder('—'),
|
|
])
|
|
->headerActions([
|
|
Actions\CreateAction::make()->mutateFormDataUsing(function (array $data, RelationManager $livewire): array {
|
|
$wo = $livewire->getOwnerRecord();
|
|
$data['client_id'] = $wo->client_id;
|
|
$data['user_id'] = auth()->id();
|
|
return $data;
|
|
}),
|
|
])
|
|
->actions([
|
|
Actions\EditAction::make(),
|
|
Actions\DeleteAction::make(),
|
|
])
|
|
->defaultSort('paid_at', 'desc');
|
|
}
|
|
}
|