diff --git a/app/Http/Controllers/Admin/SettingController.php b/app/Http/Controllers/Admin/SettingController.php
new file mode 100644
index 0000000..f7ff310
--- /dev/null
+++ b/app/Http/Controllers/Admin/SettingController.php
@@ -0,0 +1,61 @@
+ SiteSettingsService::logoUrl(),
+ 'registrationEnabled' => SiteSettingsService::registrationEnabled(),
+ ]);
+ }
+
+ public function updateLogo(Request $request): RedirectResponse
+ {
+ $request->validate([
+ 'logo' => ['required', 'file', 'max:2048', 'mimes:png,jpg,jpeg,gif,webp,svg'],
+ ]);
+
+ // Supprimer l'ancien logo
+ $old = SiteSettingsService::get('logo_path');
+ if ($old && Storage::disk('public')->exists($old)) {
+ Storage::disk('public')->delete($old);
+ }
+
+ $file = $request->file('logo');
+ $ext = strtolower($file->getClientOriginalExtension());
+ $path = Storage::disk('public')->putFileAs('site', $file, "logo.{$ext}");
+
+ SiteSettingsService::set('logo_path', $path);
+
+ return back()->with('success', 'Logo mis à jour.');
+ }
+
+ public function deleteLogo(): RedirectResponse
+ {
+ $path = SiteSettingsService::get('logo_path');
+ if ($path && Storage::disk('public')->exists($path)) {
+ Storage::disk('public')->delete($path);
+ }
+
+ SiteSettingsService::set('logo_path', null);
+
+ return back()->with('success', 'Logo supprimé.');
+ }
+
+ public function updateSettings(Request $request): RedirectResponse
+ {
+ SiteSettingsService::set('registration_enabled', $request->boolean('registration_enabled'));
+
+ return back()->with('success', 'Paramètres enregistrés.');
+ }
+}
diff --git a/app/Http/Controllers/Auth/RegisteredUserController.php b/app/Http/Controllers/Auth/RegisteredUserController.php
index 44a3930..550d2b0 100644
--- a/app/Http/Controllers/Auth/RegisteredUserController.php
+++ b/app/Http/Controllers/Auth/RegisteredUserController.php
@@ -4,9 +4,11 @@ namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Models\User;
+use App\Services\SiteSettingsService;
use Illuminate\Auth\Events\Registered;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
+use Illuminate\Http\Response;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Illuminate\Validation\Rules;
@@ -18,8 +20,13 @@ class RegisteredUserController extends Controller
/**
* Display the registration view.
*/
- public function create(): View
+ public function create(): View|RedirectResponse
{
+ if (! SiteSettingsService::registrationEnabled()) {
+ return redirect()->route('login')
+ ->with('status', 'Les inscriptions sont actuellement désactivées.');
+ }
+
return view('auth.register');
}
@@ -30,6 +37,10 @@ class RegisteredUserController extends Controller
*/
public function store(Request $request): RedirectResponse
{
+ if (! SiteSettingsService::registrationEnabled()) {
+ abort(403, 'Les inscriptions sont désactivées.');
+ }
+
$request->validate([
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'lowercase', 'email', 'max:255', 'unique:'.User::class],
diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php
index 452e6b6..0bb5275 100644
--- a/app/Providers/AppServiceProvider.php
+++ b/app/Providers/AppServiceProvider.php
@@ -2,23 +2,21 @@
namespace App\Providers;
+use App\Services\SiteSettingsService;
+use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
- /**
- * Register any application services.
- */
- public function register(): void
- {
- //
- }
+ public function register(): void {}
- /**
- * Bootstrap any application services.
- */
public function boot(): void
{
- //
+ // Partage le logo et les paramètres globaux avec toutes les vues
+ $logoUrl = SiteSettingsService::logoUrl();
+ $registrationEnabled = SiteSettingsService::registrationEnabled();
+
+ View::share('siteLogoUrl', $logoUrl);
+ View::share('registrationEnabled', $registrationEnabled);
}
}
diff --git a/app/Services/SiteSettingsService.php b/app/Services/SiteSettingsService.php
new file mode 100644
index 0000000..9bb8502
--- /dev/null
+++ b/app/Services/SiteSettingsService.php
@@ -0,0 +1,70 @@
+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);
+ }
+}
diff --git a/resources/views/admin/parametres/index.blade.php b/resources/views/admin/parametres/index.blade.php
new file mode 100644
index 0000000..78c7850
--- /dev/null
+++ b/resources/views/admin/parametres/index.blade.php
@@ -0,0 +1,77 @@
+
+
+
Paramètres du site
+
+
+
+
+ @if(session('success'))
+
{{ session('success') }}
+ @endif
+
+ {{-- Logo --}}
+
+
Logo du site
+
+ @if($logoUrl)
+
+
+
+
Logo actuel
+
+
+
+ @else
+
Aucun logo configuré — le nom de l'application est affiché.
+ @endif
+
+
+
+
+ {{-- Inscriptions --}}
+
+
Inscriptions
+
+ Autorise ou non les visiteurs à créer un compte via la page d'inscription publique.
+ Quand désactivées, seul un administrateur peut créer des comptes (via la gestion des utilisateurs).
+