string('slug')->primary(); $table->string('name'); $table->timestamps(); }); Schema::create('invoice_status', function (Blueprint $table) { $table->string('slug')->primary(); $table->timestamps(); }); Schema::create('invoices', function (Blueprint $table) { $table->id(); $table->string('tenant'); $table->foreignId('cost_unit_id')->constrained('cost_units', 'id')->cascadeOnDelete()->cascadeOnUpdate(); $table->string('invoice_number'); $table->string('status'); $table->string('type'); $table->string('type_other')->nullable(); $table->boolean('donation')->default(false); $table->foreignId('user_id')->nullable()->constrained('users', 'id')->cascadeOnDelete()->cascadeOnUpdate(); $table->string('contact_name'); $table->string('contact_email')->nullable(); $table->string('contact_phone')->nullable(); $table->string('contact_bank_owner')->nullable(); $table->string('contact_bank_iban')->nullable(); $table->float('amount', 2); $table->integer('distance')->nullable(); $table->string('comment')->nullable(); $table->longText('changes')->nullable(); $table->string('travel_direction')->nullable(); $table->boolean('passengers')->nullable(); $table->boolean('transportation')->nullable(); $table->string('document_filename')->nullable(); $table->foreignId('approved_by')->nullable()->constrained('users', 'id')->cascadeOnDelete()->cascadeOnUpdate(); $table->dateTime('approved_at')->nullable(); $table->boolean('upload_required')->default(false); $table->foreignId('denied_by')->nullable()->constrained('users', 'id')->cascadeOnDelete()->cascadeOnUpdate(); $table->dateTime('denied_at')->nullable(); $table->string('denied_reason')->nullable(); $table->foreign('tenant')->references('slug')->on('tenants')->cascadeOnDelete()->cascadeOnUpdate(); $table->foreign('type')->references('slug')->on('invoice_types')->cascadeOnDelete()->cascadeOnUpdate(); $table->foreign('status')->references('slug')->on('invoice_status')->cascadeOnDelete()->cascadeOnUpdate(); $table->timestamps(); }); } public function down(): void { Schema::dropIfExists('invoices'); Schema::dropIfExists('invoice_status'); Schema::dropIfExists('invoice_types'); } };