Files
autocrm/app/Filament/Tenant/Resources/BodyshopJobResource/RelationManagers/DamagePointsRelationManager.php
T
Vasyka e969bb9c7d i18n: wrap all formatStateUsing(fn(\$s)=>X::CONST[\$s]??\$s) with __() (21 files)
Previous sed pass only matched \$state; missed \$s and other arg-name
variants. This time the regex is arg-name-agnostic and touches 21
files across Filament resources & relation managers.

Also wraps two special cases: UserResource role-labels lookup and
LaborResource pricing_mode ternary ('Fix' | 'Pe oră').

+27 human translations for the enum values that were still identity
fallback: WorkOrderWork.STATUSES (De făcut), Purchase.STATUSES,
OnlineOrder.STATUSES, Call.DIRECTIONS/STATUSES, BodyshopJob.TYPES/
STATUSES, TireSet.SEASONS, MessageTemplate.CHANNELS,
DamagePoint.SEVERITIES, ServiceTemplateItem.KINDS.

All 306 tests pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-07-16 07:41:35 +00:00

65 lines
2.6 KiB
PHP

<?php
namespace App\Filament\Tenant\Resources\BodyshopJobResource\RelationManagers;
use App\Models\Tenant\DamagePoint;
use Filament\Actions;
use Filament\Forms;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Schemas\Schema;
use Filament\Tables;
use Filament\Tables\Table;
class DamagePointsRelationManager extends RelationManager
{
protected static string $relationship = 'damagePoints';
protected static ?string $title = null;
public static function getTitle(\Illuminate\Database\Eloquent\Model $ownerRecord, string $pageClass): string
{
return __('Hartă daune');
}
public function form(Schema $schema): Schema
{
return $schema->components([
Forms\Components\Select::make('zone')
->label(__('Zonă'))
->options(\App\Support\I18n::opts(array_combine(DamagePoint::ZONES, DamagePoint::ZONES)))
->searchable()
->required(),
Forms\Components\Select::make('kind')
->label(__('Tip daună'))
->options(\App\Support\I18n::opts(array_combine(DamagePoint::KINDS, DamagePoint::KINDS)))
->required(),
Forms\Components\Select::make('severity')
->label(__('Gravitate'))
->options(\App\Support\I18n::opts(DamagePoint::SEVERITIES))
->default('minor')
->required(),
Forms\Components\Textarea::make('notes')->label(__('Observații'))->rows(2)->columnSpanFull(),
]);
}
public function table(Table $table): Table
{
return $table
->recordTitleAttribute('zone')
->columns([
Tables\Columns\TextColumn::make('zone')->label(__('Zonă'))->badge()->color('gray'),
Tables\Columns\TextColumn::make('kind')->label(__('Tip')),
Tables\Columns\TextColumn::make('severity')
->label(__('Gravitate'))
->formatStateUsing(fn ($s) => __(DamagePoint::SEVERITIES[$s] ?? $s))
->badge()
->colors(['gray' => ['minor'], 'warning' => ['medium'], 'danger' => ['severe']]),
Tables\Columns\TextColumn::make('notes')->limit(40)->placeholder('—'),
])
->headerActions([Actions\CreateAction::make()])
->actions([Actions\EditAction::make(), Actions\DeleteAction::make()])
->emptyStateHeading(__('Nicio daună marcată'))
->emptyStateDescription(__('Adaugă punctele de daună pe zone (capotă, ușă, aripă) cu tip și gravitate — formează harta de daune a mașinii.'));
}
}