createTable('invoices', function($table) { $table->bigInteger('id')->autoIncrement()->notNull(); $table->string('invoice_number', 50)->notNull()->unique(); $table->string('customer_name', 255)->notNull(); $table->string('customer_email', 255)->nullable(); $table->decimal('amount', 10, 2)->notNull(); $table->decimal('tax_amount', 10, 2)->default(0.00)->notNull(); $table->decimal('total_amount', 10, 2)->notNull(); $table->enum('status', ['draft', 'pending', 'paid', 'cancelled', 'refunded'])->default('draft')->notNull(); $table->enum('currency', ['EUR', 'USD', 'GBP'])->default('EUR')->notNull(); $table->date('due_date')->nullable(); $table->date('paid_date')->nullable(); $table->text('notes')->nullable(); $table->json('items')->nullable(); // Array de itens da fatura $table->string('payment_method', 100)->nullable(); $table->string('payment_reference', 255)->nullable(); $table->bigInteger('created_by')->nullable(); $table->timestamp('created_at')->default('CURRENT_TIMESTAMP')->notNull(); $table->timestamp('updated_at')->default('CURRENT_TIMESTAMP')->notNull(); $table->timestamp('deleted_at')->nullable(); $table->primaryKey('id'); $table->index(['status', 'due_date']); $table->index(['customer_email']); $table->index(['created_by']); }); } public function down(): void { $this->dropTable('invoices'); } }