<?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('repair_orders', function (Blueprint $table) {
$table->id();
$table->string('order_number', 50)->unique();
$table->foreignId('user_id')->constrained('users'); // клиент
$table->foreignId('car_id')->constrained('cars');
$table->foreignId('admin_id')->nullable()->constrained('users'); // администратор, который принял заказ
$table->enum('status', [
'pending', // ожидает
'in_progress', // в работе
'completed', // завершён
'cancelled' // отменён
])->default('pending');
$table->date('order_date');
$table->date('completion_date')->nullable();
$table->text('problem_description')->nullable();
$table->text('admin_notes')->nullable();
$table->decimal('total_labor_cost', 10, 2)->default(0);
$table->decimal('total_parts_cost', 10, 2)->default(0);
$table->decimal('total_amount', 10, 2)->default(0);
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('repair_orders');
}
};