schneespur/app/Http/Controllers/Admin/BrandingController.php
Michael 2c63440ed8 Revert: move code back to project root from schneespur/ subdirectory
- Reverts the schneespur/ subdirectory restructure (b8e426b)
- Restores package.json and vite.config.js (needed for npm build, were
  removed in an earlier cleanup before the restructure)
- Updates public/build/ assets with current Vite output (new content hashes)
2026-05-17 18:24:26 +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'));
}
}