Refactor code structure for improved readability and maintainability
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
<?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('sistemi', function (Blueprint $table) {
|
||||
$table->id();
|
||||
// Codice usato dal configuratore nel parametro ?sistema= (es. "pvc").
|
||||
$table->string('codice', 50)->unique();
|
||||
$table->string('nome');
|
||||
$table->unsignedInteger('ordine')->default(0);
|
||||
$table->boolean('attivo')->default(true);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('sistemi');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,42 @@
|
||||
<?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('modelli', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('sistema_id')->constrained('sistemi')->cascadeOnDelete();
|
||||
// Codice interno: è anche il ?type= del configuratore.
|
||||
$table->string('codice', 100);
|
||||
// Etichetta mostrata nella lista modelli del configuratore.
|
||||
$table->string('nome');
|
||||
// Descrizione d'ordine (es. "FINESTRA 1 ANTA, A/R").
|
||||
$table->string('descrizione')->nullable();
|
||||
$table->string('icona')->nullable();
|
||||
$table->unsignedInteger('ordine')->default(0);
|
||||
$table->boolean('attivo')->default(true);
|
||||
|
||||
// Configurazione 3D letta dal configuratore.
|
||||
$table->string('cartella')->nullable();
|
||||
$table->string('file_modello')->nullable();
|
||||
$table->string('categoria', 50)->nullable();
|
||||
$table->string('cartella_texture')->nullable();
|
||||
$table->json('moduli')->nullable();
|
||||
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['sistema_id', 'codice']);
|
||||
$table->index(['sistema_id', 'attivo', 'ordine']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('modelli');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user