Initial commit

This commit is contained in:
2026-04-12 06:24:30 +00:00
commit 007f107be6
213 changed files with 25576 additions and 0 deletions
@@ -0,0 +1,70 @@
<?php
namespace App\Http\Controllers;
use App\Models\AppSetting;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
use Illuminate\View\View;
use RealRashid\SweetAlert\Facades\Alert;
class BrandingSettingController extends Controller
{
public function index(): View
{
return view('settings.branding', [
'branding' => AppSetting::branding(),
]);
}
public function update(Request $request): RedirectResponse
{
$data = $request->validate([
'app_name' => ['required', 'string', 'max:255'],
'app_short_name' => ['required', 'string', 'max:20'],
'app_logo' => ['nullable', 'image', 'mimes:jpg,jpeg,png,webp,svg', 'max:2048'],
'app_favicon' => ['nullable', 'image', 'mimes:jpg,jpeg,png,webp,svg,ico', 'max:1024'],
'public_portal_logo' => ['nullable', 'image', 'mimes:jpg,jpeg,png,webp,svg', 'max:2048'],
'remove_app_logo' => ['nullable', 'boolean'],
'remove_app_favicon' => ['nullable', 'boolean'],
'remove_public_portal_logo' => ['nullable', 'boolean'],
]);
AppSetting::setValue('app_name', $data['app_name']);
AppSetting::setValue('app_short_name', $data['app_short_name']);
$this->handleAssetUpdate($request, 'app_logo', 'branding/app-logo', (bool) ($data['remove_app_logo'] ?? false));
$this->handleAssetUpdate($request, 'app_favicon', 'branding/app-favicon', (bool) ($data['remove_app_favicon'] ?? false));
$this->handleAssetUpdate($request, 'public_portal_logo', 'branding/public-portal-logo', (bool) ($data['remove_public_portal_logo'] ?? false));
Alert::success('Berhasil', 'Pengaturan branding aplikasi berhasil diperbarui.');
return redirect()->route('settings.branding.index')->with('success', 'Pengaturan branding aplikasi berhasil diperbarui.');
}
protected function handleAssetUpdate(Request $request, string $field, string $directory, bool $remove = false): void
{
$currentPath = AppSetting::getValue($field);
if ($remove) {
if ($currentPath && Storage::disk('public')->exists($currentPath)) {
Storage::disk('public')->delete($currentPath);
}
AppSetting::setValue($field, null);
return;
}
if (! $request->hasFile($field)) {
return;
}
if ($currentPath && Storage::disk('public')->exists($currentPath)) {
Storage::disk('public')->delete($currentPath);
}
$path = $request->file($field)->store($directory, 'public');
AppSetting::setValue($field, $path);
}
}