5e255b7b40
Completes the 18-stage roadmap (17/18 fully functional, 18 partial). Schema: - bodyshop_jobs (type body_repair/pdr/painting/detailing/ceramic/ppf/polishing, status workflow, insurance case fields, estimate/approved amounts) - damage_points (zone, kind, severity) — the damage map Models: - BodyshopJob (HasMedia: photos_before/photos_after), auto number BS-YY-NNNN - DamagePoint with ZONES/KINDS/SEVERITIES Filament (new "Tinichigerie" nav group): - BodyshopJobResource: type/status, collapsible insurance section (conditional fields), before/after photo upload, estimate/approved amounts - DamagePointsRelationManager (zone + kind + colour-coded severity) - Table with type badge, insurance flag, damage count; nav badge = open jobs Tests (5 new): - auto number; damage points relation; insurance fields persist; detailing types supported; tenant isolation Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
60 lines
2.4 KiB
PHP
60 lines
2.4 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 = 'Hartă daune';
|
|
|
|
public function form(Schema $schema): Schema
|
|
{
|
|
return $schema->components([
|
|
Forms\Components\Select::make('zone')
|
|
->label('Zonă')
|
|
->options(array_combine(DamagePoint::ZONES, DamagePoint::ZONES))
|
|
->searchable()
|
|
->required(),
|
|
Forms\Components\Select::make('kind')
|
|
->label('Tip daună')
|
|
->options(array_combine(DamagePoint::KINDS, DamagePoint::KINDS))
|
|
->required(),
|
|
Forms\Components\Select::make('severity')
|
|
->label('Gravitate')
|
|
->options(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.');
|
|
}
|
|
}
|