id(); $table->string('protocollo')->nullable()->unique(); // es. 2025-0001 $table->date('data_protocollo')->nullable(); $table->string('tipo_documento')->nullable(); // Fattura, Contratto, Verbale, ecc. $table->unsignedBigInteger('stabile_id')->nullable(); $table->unsignedBigInteger('fornitore_id')->nullable(); $table->unsignedBigInteger('esercizio_contabile_id')->nullable(); $table->text('descrizione')->nullable(); $table->decimal('importo', 12, 2)->nullable(); $table->date('data_documento')->nullable(); $table->string('nome_file'); $table->string('path_file'); $table->text('testo_estratto_ocr')->nullable(); // Polimorfismo $table->unsignedBigInteger('documentable_id')->nullable()->index(); $table->string('documentable_type')->nullable()->index(); $table->timestamps(); // FK opzionali $table->foreign('stabile_id')->references('id')->on('stabili')->onDelete('set null'); $table->foreign('fornitore_id')->references('id')->on('fornitori')->onDelete('set null'); // $table->foreign('esercizio_contabile_id')->references('id')->on('esercizi_contabili')->onDelete('set null'); // FK disabilitata: tabella non ancora presente }); } public function down(): void { Schema::dropIfExists('documenti'); } };