- Aggiunto dark mode completo alla sidebar con classi Tailwind - Implementato sistema di salvataggio permanente delle impostazioni utente - Creata tabella user_settings per gestire preferenze personalizzate - Aggiunto model UserSetting con metodi helper get/set - Esteso controller impostazioni per supportare salvataggio e temi predefiniti - Applicato stesso tema anche al pannello amministratore - Aggiornate route per gestione temi in admin e superadmin - Integrato sistema impostazioni nel layout principale con variabili CSS - Aggiornato AppServiceProvider con helper userSetting() - Dark mode applicato a: sidebar, modali, footer, bottoni, hover states - Temi predefiniti: Default, Dark, Ocean con preview tempo reale - Compatibilità completa tra pannello admin e superadmin
41 lines
847 B
PHP
41 lines
847 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class UserSetting extends Model
|
|
{
|
|
protected $fillable = ['user_id', 'key', 'value'];
|
|
|
|
public function user()
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
public static function get($key, $default = null)
|
|
{
|
|
if (!auth()->check()) {
|
|
return $default;
|
|
}
|
|
|
|
$setting = static::where('user_id', auth()->id())
|
|
->where('key', $key)
|
|
->first();
|
|
|
|
return $setting ? $setting->value : $default;
|
|
}
|
|
|
|
public static function set($key, $value)
|
|
{
|
|
if (!auth()->check()) {
|
|
return false;
|
|
}
|
|
|
|
return static::updateOrCreate(
|
|
['user_id' => auth()->id(), 'key' => $key],
|
|
['value' => $value]
|
|
);
|
|
}
|
|
}
|