++ Primo Caricamento
This commit is contained in:
44
app/Models/Setting.php
Normal file
44
app/Models/Setting.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
// Model Setting — gestisce le impostazioni dinamiche dell'applicazione
|
||||
//
|
||||
// Ogni riga della tabella `settings` è una coppia chiave-valore.
|
||||
// Esempio:
|
||||
// key: "items_per_page" value: "15"
|
||||
// key: "currency_symbol" value: "€"
|
||||
//
|
||||
// I valori sono sempre stringhe nel DB. SettingService gestisce il cast
|
||||
// al tipo corretto (int, bool, string, ecc.) basandosi su config/settings.php
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Setting extends Model
|
||||
{
|
||||
protected $table = 'settings';
|
||||
|
||||
protected $fillable = [
|
||||
'key',
|
||||
'value',
|
||||
'label', // Nome leggibile mostrato nel pannello admin
|
||||
'group', // Gruppo di appartenenza (es. "Azienda", "Visualizzazione")
|
||||
'type', // Tipo dato: string, integer, boolean, text
|
||||
];
|
||||
|
||||
// Non usiamo timestamps per le impostazioni (semplifica la tabella)
|
||||
public $timestamps = true;
|
||||
|
||||
// ─── Scope: cerca per chiave ──────────────────────────────────────────
|
||||
public function scopeForKey($query, string $key)
|
||||
{
|
||||
return $query->where('key', $key);
|
||||
}
|
||||
|
||||
public function scopeInGroup($query, string $group)
|
||||
{
|
||||
return $query->where('group', $group);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user