Stage 10 — Bodyshop / PDR / Detailing: damage map + insurance + photos

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>
This commit is contained in:
2026-05-28 06:49:47 +00:00
parent e8078f157a
commit 5e255b7b40
9 changed files with 532 additions and 0 deletions
@@ -0,0 +1,60 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('bodyshop_jobs', function (Blueprint $t) {
$t->id();
$t->foreignId('company_id')->constrained()->cascadeOnDelete();
$t->foreignId('work_order_id')->nullable()->constrained()->nullOnDelete();
$t->foreignId('client_id')->nullable()->constrained()->nullOnDelete();
$t->foreignId('vehicle_id')->nullable()->constrained()->nullOnDelete();
$t->string('number', 32);
$t->string('type', 24)->default('body_repair'); // body_repair/pdr/painting/detailing/ceramic/ppf/polishing
$t->string('status', 16)->default('estimate'); // estimate/approved/in_progress/done/delivered/cancelled
// Insurance case
$t->boolean('is_insurance')->default(false);
$t->string('insurer')->nullable();
$t->string('policy_no', 64)->nullable();
$t->string('claim_no', 64)->nullable();
$t->string('insurance_status', 24)->nullable(); // submitted/approved/rejected/paid
$t->decimal('estimate_amount', 12, 2)->default(0);
$t->decimal('approved_amount', 12, 2)->default(0);
$t->text('notes')->nullable();
$t->timestamps();
$t->softDeletes();
$t->unique(['company_id', 'number']);
$t->index(['company_id', 'status']);
$t->index(['company_id', 'type']);
});
Schema::create('damage_points', function (Blueprint $t) {
$t->id();
$t->foreignId('company_id')->constrained()->cascadeOnDelete();
$t->foreignId('bodyshop_job_id')->constrained()->cascadeOnDelete();
$t->string('zone', 40); // Capotă / Aripă FS / Ușă SD / ...
$t->string('kind', 32); // Zgârietură / Lovitură / Fisură / Rugină / ...
$t->string('severity', 12)->default('minor'); // minor/medium/severe
$t->text('notes')->nullable();
$t->timestamps();
$t->index(['company_id', 'bodyshop_job_id']);
});
}
public function down(): void
{
Schema::dropIfExists('damage_points');
Schema::dropIfExists('bodyshop_jobs');
}
};