?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('invoices', function (Blueprint $table) { $table->id(); $table->string('invoice_number')->unique(); $table->foreignId('customer_id')->constrained()->cascadeOnDelete()->index(); $table->foreignId('company_id')->nullable()->constrained()->nullOnDelete()->index(); $table->string('currency', 3)->default('USD'); $table->string('status')->default('draft')->index(); $table->decimal('subtotal', 12, 4)->default(0); $table->decimal('tax_total', 12, 4)->default(0); $table->decimal('discount_total', 12, 4)->default(0); $table->decimal('total', 12, 4)->default(0); $table->decimal('amount_paid', 12, 4)->default(0); $table->decimal('amount_due', 12, 4)->default(0); $table->date('issue_date'); $table->date('due_date')->index(); $table->timestamp('paid_at')->nullable(); $table->text('notes')->nullable(); $table->text('terms')->nullable(); $table->string('pdf_path')->nullable(); $table->timestamps(); }); } public function down(): void { Schema::dropIfExists('invoices'); } };