f341f822ab
Ajoute une section "Version du logiciel" dans admin/parametres avec : - version installée + date d'installation - bandeau de mise à jour disponible si nouvelle version détectée - badge "À jour" si à jour (même logique que le tableau de bord admin) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
71 lines
2.3 KiB
PHP
71 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Services\SiteSettingsService;
|
|
use App\Services\UpdateService;
|
|
use Illuminate\Http\RedirectResponse;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Storage;
|
|
use Illuminate\View\View;
|
|
|
|
class SettingController extends Controller
|
|
{
|
|
public function index(UpdateService $updates): View
|
|
{
|
|
$installedVersion = $updates->getInstalledVersion();
|
|
$latestRelease = $updates->fetchLatestRelease();
|
|
$updateAvailable = $latestRelease
|
|
&& version_compare($latestRelease['version'], $installedVersion, '>');
|
|
|
|
return view('admin.parametres.index', [
|
|
'logoUrl' => SiteSettingsService::logoUrl(),
|
|
'registrationEnabled' => SiteSettingsService::registrationEnabled(),
|
|
'installedVersion' => $installedVersion,
|
|
'latestRelease' => $latestRelease,
|
|
'updateAvailable' => $updateAvailable,
|
|
]);
|
|
}
|
|
|
|
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.');
|
|
}
|
|
}
|