Logo du site, favicon et contrôle des inscriptions

SiteSettingsService : persistance JSON dans storage/app/site_settings.json
  (pas de migration DB — survit aux mises à jour sans table supplémentaire)

Logo :
- Upload admin (PNG/JPG/SVG/WebP, max 2 Mo) → storage/app/public/site/logo.{ext}
- Favicon <link rel="icon"> injecté dans app.blade.php et guest.blade.php
- Logo affiché dans la barre de navigation (h-8, object-contain)
- Logo affiché sur la page de connexion (guest layout)
- Page d'accueil welcome.blade.php entièrement refaite : logo + bouton connexion
  (remplacement du template Laravel par défaut)
- Suppression du logo possible depuis Admin > Paramètres du site

Inscriptions :
- Désactivées par défaut (registration_enabled=false dans site_settings.json)
- RegisteredUserController : redirige vers /login si inscription désactivée
  (GET /register → redirect + message ; POST /register → abort 403)
- Page d'accueil : bouton "Créer un compte" masqué si inscriptions désactivées
- Admin > Paramètres du site : toggle checkbox pour activer/désactiver

AppServiceProvider : partage $siteLogoUrl et $registrationEnabled avec toutes les vues

Navigation : lien "Paramètres du site" en bas du menu Administration

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-04 18:01:38 +02:00
parent cd9cc94895
commit f57ae068b9
10 changed files with 312 additions and 285 deletions
+70
View File
@@ -0,0 +1,70 @@
<?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;
}
}
// ── Inscriptions ─────────────────────────────────────────────────────────
public static function registrationEnabled(): bool
{
// Désactivées par défaut
return (bool) self::get('registration_enabled', false);
}
}