schneespur/app/Http/Controllers/Admin/BrandingController.php
Michael ee3dbba6cc Initial release v1.0.0
Schneespur — Open-source winter service documentation software (PWA + Admin).
GPS tracking via OwnTracks, weather data, photo evidence, and legally
compliant service records for winter maintenance operators.

License: AGPL-3.0-or-later
2026-05-17 13:33:51 +00:00

54 lines
1.5 KiB
PHP

<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Models\Setting;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
use Illuminate\View\View;
class BrandingController extends Controller
{
public function edit(): View
{
return view('admin.settings.branding', [
'logoPath' => Setting::get('company_logo_path'),
]);
}
public function update(Request $request): RedirectResponse
{
$request->validate([
'company_logo' => ['nullable', 'image', 'mimes:png,jpg,jpeg,svg', 'max:2048'],
]);
if ($request->hasFile('company_logo')) {
$oldPath = Setting::get('company_logo_path');
if ($oldPath && Storage::disk('public')->exists($oldPath)) {
Storage::disk('public')->delete($oldPath);
}
$path = $request->file('company_logo')->store('branding', 'public');
Setting::set('company_logo_path', $path);
}
return redirect()->route('admin.settings.branding')
->with('success', __('ui.saved'));
}
public function deleteLogo(): RedirectResponse
{
$path = Setting::get('company_logo_path');
if ($path && Storage::disk('public')->exists($path)) {
Storage::disk('public')->delete($path);
}
Setting::set('company_logo_path', '');
return redirect()->route('admin.settings.branding')
->with('success', __('ui.saved'));
}
}