fix: add table existence checks in Onboarding components to prevent errors and improve modal behavior
This commit is contained in:
@@ -6,6 +6,7 @@ use Livewire\Component;
|
|||||||
use Paymenter\Extensions\Others\Onboarding\Models\OnboardingSlide;
|
use Paymenter\Extensions\Others\Onboarding\Models\OnboardingSlide;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
use App\Helpers\ExtensionHelper;
|
use App\Helpers\ExtensionHelper;
|
||||||
|
|
||||||
class Modal extends Component
|
class Modal extends Component
|
||||||
@@ -16,6 +17,12 @@ class Modal extends Component
|
|||||||
|
|
||||||
public function mount()
|
public function mount()
|
||||||
{
|
{
|
||||||
|
// Guard: ensure table exists before querying
|
||||||
|
if (!Schema::hasTable('ext_onboarding_slides')) {
|
||||||
|
$this->showModal = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Check if test mode and per session mode are enabled
|
// Check if test mode and per session mode are enabled
|
||||||
$extension = ExtensionHelper::getExtension('other', 'Onboarding');
|
$extension = ExtensionHelper::getExtension('other', 'Onboarding');
|
||||||
$testMode = $extension->config('test_mode', false);
|
$testMode = $extension->config('test_mode', false);
|
||||||
@@ -35,10 +42,15 @@ class Modal extends Component
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Only show if user hasn't seen it and there are slides
|
// Only show if user hasn't seen it and there are slides
|
||||||
$this->slides = OnboardingSlide::where('enabled', true)
|
try {
|
||||||
->orderBy('sort', 'asc')
|
$this->slides = OnboardingSlide::where('enabled', true)
|
||||||
->get()
|
->orderBy('sort', 'asc')
|
||||||
->toArray();
|
->get()
|
||||||
|
->toArray();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// If query fails (e.g., missing columns), don't show modal
|
||||||
|
$this->slides = [];
|
||||||
|
}
|
||||||
|
|
||||||
$this->showModal = !$hasSeenOnboarding && count($this->slides) > 0 && $this->currentSlide < count($this->slides);
|
$this->showModal = !$hasSeenOnboarding && count($this->slides) > 0 && $this->currentSlide < count($this->slides);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace Paymenter\Extensions\Others\Onboarding;
|
|||||||
|
|
||||||
use App\Classes\Extension\Extension;
|
use App\Classes\Extension\Extension;
|
||||||
use App\Helpers\ExtensionHelper;
|
use App\Helpers\ExtensionHelper;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
class Onboarding extends Extension
|
class Onboarding extends Extension
|
||||||
{
|
{
|
||||||
@@ -84,6 +85,11 @@ class Onboarding extends Extension
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// Only register body hook if the table exists
|
||||||
|
if (!Schema::hasTable('ext_onboarding_slides')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
\Illuminate\Support\Facades\Event::listen('body', function () {
|
\Illuminate\Support\Facades\Event::listen('body', function () {
|
||||||
|
|
||||||
if (!request()->is('admin/*') &&
|
if (!request()->is('admin/*') &&
|
||||||
@@ -96,7 +102,7 @@ class Onboarding extends Extension
|
|||||||
!request()->is('/') &&
|
!request()->is('/') &&
|
||||||
\Illuminate\Support\Facades\Auth::check()) {
|
\Illuminate\Support\Facades\Auth::check()) {
|
||||||
return [
|
return [
|
||||||
'view' => view('onboarding::widget'),
|
'view' => view('onboarding::widget')->render(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -11,22 +11,23 @@
|
|||||||
document.documentElement.style.overflow = '';
|
document.documentElement.style.overflow = '';
|
||||||
}
|
}
|
||||||
})"
|
})"
|
||||||
class="fixed inset-0 z-50 flex items-center justify-center overflow-hidden">
|
class="fixed inset-0 z-50 flex items-center justify-center overflow-hidden pointer-events-none">
|
||||||
|
|
||||||
|
|
||||||
@if($this->showBackdrop)
|
@if($this->showBackdrop)
|
||||||
<div class="absolute inset-0 bg-black/50 transition-opacity duration-300"
|
<div class="absolute inset-0 bg-black/50 transition-opacity duration-300 pointer-events-auto"
|
||||||
x-show="open"
|
x-show="open"
|
||||||
x-transition:enter="transition ease-out duration-300"
|
x-transition:enter="transition ease-out duration-300"
|
||||||
x-transition:enter-start="opacity-0"
|
x-transition:enter-start="opacity-0"
|
||||||
x-transition:enter-end="opacity-100"
|
x-transition:enter-end="opacity-100"
|
||||||
x-transition:leave="transition ease-in duration-300"
|
x-transition:leave="transition ease-in duration-300"
|
||||||
x-transition:leave-start="opacity-100"
|
x-transition:leave-start="opacity-100"
|
||||||
x-transition:leave-end="opacity-0"></div>
|
x-transition:leave-end="opacity-0"
|
||||||
|
wire:click="finish"></div>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
|
||||||
<div class="w-full max-w-xl mx-4 md:mx-auto bg-background-secondary border border-neutral rounded-lg shadow-2xl overflow-hidden h-[500px] flex flex-col relative z-10"
|
<div class="w-full max-w-xl mx-4 md:mx-auto bg-background-secondary border border-neutral rounded-lg shadow-2xl overflow-hidden h-[500px] flex flex-col relative z-10 pointer-events-auto"
|
||||||
x-show="open"
|
x-show="open"
|
||||||
x-transition:enter="transition ease-out duration-300"
|
x-transition:enter="transition ease-out duration-300"
|
||||||
x-transition:enter-start="opacity-0 scale-90"
|
x-transition:enter-start="opacity-0 scale-90"
|
||||||
|
|||||||
Reference in New Issue
Block a user