30 lines
766 B
PHP
30 lines
766 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Models\Concerns;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Thème (clair/sombre/système) et taille du texte, pour le menu
|
||
|
|
* Paramètres de la barre du haut — partagé entre User et Eleve.
|
||
|
|
*/
|
||
|
|
trait GerePreferences
|
||
|
|
{
|
||
|
|
public const THEMES = ['clair', 'sombre', 'systeme'];
|
||
|
|
|
||
|
|
public const TAILLES_TEXTE = ['normal', 'grand'];
|
||
|
|
|
||
|
|
public function preferenceTheme(): string
|
||
|
|
{
|
||
|
|
return $this->preferences['theme'] ?? 'systeme';
|
||
|
|
}
|
||
|
|
|
||
|
|
public function preferenceTailleTexte(): string
|
||
|
|
{
|
||
|
|
return $this->preferences['taille_texte'] ?? 'normal';
|
||
|
|
}
|
||
|
|
|
||
|
|
public function definirPreferences(string $theme, string $tailleTexte): void
|
||
|
|
{
|
||
|
|
$this->forceFill(['preferences' => ['theme' => $theme, 'taille_texte' => $tailleTexte]])->save();
|
||
|
|
}
|
||
|
|
}
|