f530f55577
- Dark mode complet : darkMode:'class' Tailwind, sélecteur clair/sombre/auto dans la navigation (mémorisé dans localStorage, sans flash au chargement) ; 53 vues et 8 composants Breeze mis à jour avec classes dark: - Composant user-picker : fenêtre modale avec recherche temps réel (nom/email) remplace les <select> d'ajout de membres dans sections et sources - Paramètres : option "Désactiver la vérification automatique des mises à jour" (case à cochage auto-soumise, route POST parametres/updates) - Panneau "Paramètres généraux" remonté en tête de la page de paramètres - README recentré sur l'installation manuelle hébergement PHP+MySQL - VERSION 1.0.1 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
98 lines
3.1 KiB
PHP
98 lines
3.1 KiB
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use Illuminate\Support\Facades\Storage;
|
|
|
|
class SiteSettingsService
|
|
{
|
|
private static function path(): string
|
|
{
|
|
return storage_path('app/site_settings.json');
|
|
}
|
|
|
|
private static function load(): array
|
|
{
|
|
$path = self::path();
|
|
if (! file_exists($path)) {
|
|
return [];
|
|
}
|
|
return json_decode(file_get_contents($path), true) ?: [];
|
|
}
|
|
|
|
private static function save(array $settings): void
|
|
{
|
|
file_put_contents(self::path(), json_encode($settings, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
|
|
}
|
|
|
|
public static function get(string $key, mixed $default = null): mixed
|
|
{
|
|
return self::load()[$key] ?? $default;
|
|
}
|
|
|
|
public static function set(string $key, mixed $value): void
|
|
{
|
|
$settings = self::load();
|
|
$settings[$key] = $value;
|
|
self::save($settings);
|
|
}
|
|
|
|
public static function all(): array
|
|
{
|
|
return self::load();
|
|
}
|
|
|
|
// ── Logo ─────────────────────────────────────────────────────────────────
|
|
|
|
public static function logoUrl(): ?string
|
|
{
|
|
$logoPath = self::get('logo_path');
|
|
if (! $logoPath) {
|
|
return null;
|
|
}
|
|
try {
|
|
if (! Storage::disk('public')->exists($logoPath)) {
|
|
return null;
|
|
}
|
|
return Storage::disk('public')->url($logoPath);
|
|
} catch (\Exception) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
// ── SMTP ─────────────────────────────────────────────────────────────────
|
|
|
|
public static function smtpConfig(): array
|
|
{
|
|
return self::get('smtp', []);
|
|
}
|
|
|
|
public static function smtpConfigured(): bool
|
|
{
|
|
$smtp = self::smtpConfig();
|
|
return ! empty($smtp['host']) && ! empty($smtp['port']);
|
|
}
|
|
|
|
// ── Titre du site ─────────────────────────────────────────────────────────
|
|
|
|
public static function siteName(): string
|
|
{
|
|
return self::get('site_name') ?: config('app.name', 'MesRelevés');
|
|
}
|
|
|
|
// ── Inscriptions ─────────────────────────────────────────────────────────
|
|
|
|
public static function registrationEnabled(): bool
|
|
{
|
|
// Désactivées par défaut
|
|
return (bool) self::get('registration_enabled', false);
|
|
}
|
|
|
|
// ── Mises à jour ──────────────────────────────────────────────────────────
|
|
|
|
public static function updatesDisabled(): bool
|
|
{
|
|
return (bool) self::get('updates_disabled', false);
|
|
}
|
|
}
|