++ Primo Caricamento
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
// Migration: crea la tabella settings
|
||||
//
|
||||
// La tabella `settings` implementa il pattern "key-value store":
|
||||
// ogni riga è un'impostazione dell'applicazione modificabile via Admin.
|
||||
//
|
||||
// Schema:
|
||||
// id → chiave primaria
|
||||
// key → identificatore univoco dell'impostazione (es. "items_per_page")
|
||||
// value → valore come stringa (il tipo è gestito da SettingService)
|
||||
// label → nome leggibile per l'interfaccia admin
|
||||
// group → raggruppamento per il pannello (es. "Azienda", "Visualizzazione")
|
||||
// type → tipo dato per il cast corretto (string, integer, boolean, text)
|
||||
// timestamps → created_at e updated_at
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
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('settings', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
// Chiave univoca: identifica univocamente l'impostazione
|
||||
$table->string('key')->unique();
|
||||
|
||||
// Valore come testo (può essere lungo, es. messaggi)
|
||||
$table->text('value')->nullable();
|
||||
|
||||
// Metadati per il pannello admin
|
||||
$table->string('label')->nullable(); // Nome leggibile
|
||||
$table->string('group')->default('Generale'); // Gruppo
|
||||
$table->string('type')->default('string'); // Tipo PHP
|
||||
|
||||
$table->timestamps();
|
||||
|
||||
// Indice sul gruppo per caricare le impostazioni per sezione
|
||||
$table->index('group');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('settings');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user