b608501f39
Utilisateurs :
- Filtre actif/inactif dans la liste (status=active|inactive)
- Export CSV avec les filtres actifs — séparateur ;, BOM UTF-8 (compatible Excel)
- Import CSV : détection auto du séparateur, validation ligne par ligne,
mot de passe temporaire généré + affiché une seule fois dans les résultats
- Téléchargement d'un fichier modèle CSV
Paramètres du site :
- Champ "Titre du site" (site_name dans site_settings.json)
- Titre partagé via SiteSettingsService::siteName() et injecté dans config('app.name')
au boot — s'applique partout sans modifier .env
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
78 lines
2.3 KiB
PHP
78 lines
2.3 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;
|
|
}
|
|
}
|
|
|
|
// ── 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);
|
|
}
|
|
}
|