Add custom company logo upload and simplify kiosk branding.
Deploy Ladill Frontdesk / deploy (push) Successful in 23s
Deploy Ladill Frontdesk / deploy (push) Successful in 23s
Show Ladill Frontdesk or uploaded logo top-left on kiosk; allow logo upload in onboarding and organization settings. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -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!');
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
]);
|
||||
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Support;
|
||||
|
||||
use App\Models\Organization;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class OrganizationBranding
|
||||
{
|
||||
public const DEFAULT_LOGO = 'images/logo/ladillfrontdesk-logo.svg';
|
||||
|
||||
public static function logoUrl(Organization $organization): string
|
||||
{
|
||||
if ($organization->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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user