diff --git a/app/Http/Controllers/Frontdesk/OnboardingController.php b/app/Http/Controllers/Frontdesk/OnboardingController.php index e29fac1..020178d 100644 --- a/app/Http/Controllers/Frontdesk/OnboardingController.php +++ b/app/Http/Controllers/Frontdesk/OnboardingController.php @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Frontdesk; use App\Http\Controllers\Controller; use App\Http\Controllers\Frontdesk\Concerns\ScopesToAccount; use App\Services\Frontdesk\OrganizationResolver; +use App\Support\OrganizationBranding; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; use Illuminate\View\View; @@ -43,9 +44,16 @@ class OnboardingController extends Controller 'visitor_policy' => ['nullable', 'string', 'max:5000'], 'badge_expiry_hours' => ['nullable', 'integer', 'min:1', 'max:24'], 'kiosk_reset_seconds' => ['nullable', 'integer', 'min:30', 'max:600'], + 'logo' => ['nullable', 'image', 'mimes:jpeg,png,jpg,webp,svg', 'max:2048'], ]); - $this->organizations->completeOnboarding($request->user(), $validated); + $organization = $this->organizations->completeOnboarding($request->user(), $validated); + + if ($request->hasFile('logo')) { + $organization->update([ + 'logo_path' => OrganizationBranding::storeLogo($organization, $request->file('logo')), + ]); + } return redirect()->route('frontdesk.dashboard')->with('success', 'Welcome to Ladill Frontdesk!'); } diff --git a/app/Http/Controllers/Frontdesk/SettingsController.php b/app/Http/Controllers/Frontdesk/SettingsController.php index 745f3f4..05a2fc6 100644 --- a/app/Http/Controllers/Frontdesk/SettingsController.php +++ b/app/Http/Controllers/Frontdesk/SettingsController.php @@ -6,6 +6,7 @@ use App\Http\Controllers\Controller; use App\Http\Controllers\Frontdesk\Concerns\ScopesToAccount; use App\Models\Branch; use App\Services\Frontdesk\FrontdeskPermissions; +use App\Support\OrganizationBranding; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; use Illuminate\View\View; @@ -51,6 +52,8 @@ class SettingsController extends Controller 'notification_channels.*' => ['string', 'in:'.implode(',', array_keys(config('frontdesk.notification_channels')))], 'notification_events' => ['nullable', 'array'], 'report_daily_recipients' => ['nullable', 'string', 'max:2000'], + 'logo' => ['nullable', 'image', 'mimes:jpeg,png,jpg,webp,svg', 'max:2048'], + 'remove_logo' => ['nullable', 'boolean'], ]); $settings = $organization->settings ?? []; @@ -81,9 +84,21 @@ class SettingsController extends Controller ); } + $logoPath = $organization->logo_path; + + if ($request->boolean('remove_logo')) { + OrganizationBranding::deleteStoredLogo($organization); + $logoPath = null; + } + + if ($request->hasFile('logo')) { + $logoPath = OrganizationBranding::storeLogo($organization, $request->file('logo')); + } + $organization->update([ 'name' => $validated['name'], 'timezone' => $validated['timezone'], + 'logo_path' => $logoPath, 'settings' => $settings, ]); diff --git a/app/Support/OrganizationBranding.php b/app/Support/OrganizationBranding.php new file mode 100644 index 0000000..8686612 --- /dev/null +++ b/app/Support/OrganizationBranding.php @@ -0,0 +1,50 @@ +logo_path && Storage::disk('public')->exists($organization->logo_path)) { + $version = $organization->updated_at?->getTimestamp() ?? time(); + + return Storage::disk('public')->url($organization->logo_path).'?v='.$version; + } + + $path = public_path(self::DEFAULT_LOGO); + + return asset(self::DEFAULT_LOGO).'?v='.(@filemtime($path) ?: '1'); + } + + public static function logoAlt(Organization $organization): string + { + return $organization->logo_path ? $organization->name : 'Ladill Frontdesk'; + } + + public static function hasCustomLogo(Organization $organization): bool + { + return $organization->logo_path !== null + && Storage::disk('public')->exists($organization->logo_path); + } + + public static function storeLogo(Organization $organization, UploadedFile $file): string + { + self::deleteStoredLogo($organization); + + return $file->store('frontdesk/organizations/'.$organization->id, 'public'); + } + + public static function deleteStoredLogo(Organization $organization): void + { + if ($organization->logo_path) { + Storage::disk('public')->delete($organization->logo_path); + } + } +} diff --git a/resources/views/frontdesk/kiosk/index.blade.php b/resources/views/frontdesk/kiosk/index.blade.php index 0e31c3c..99350ef 100644 --- a/resources/views/frontdesk/kiosk/index.blade.php +++ b/resources/views/frontdesk/kiosk/index.blade.php @@ -1,7 +1,3 @@ -@php - $fdIcon = 'images/launcher-icons/frontdesk.svg'; - $fdLogo = 'images/logo/ladillfrontdesk-logo.svg'; -@endphp @@ -25,19 +21,13 @@
-
+
+ @include('frontdesk.partials.kiosk-brand') + +