fix: add table existence checks in Onboarding components to prevent errors and improve modal behavior

This commit is contained in:
2025-12-03 22:31:30 -05:00
parent 09c2ca33d7
commit ea471aa6a9
3 changed files with 28 additions and 9 deletions

View File

@@ -6,6 +6,7 @@ use Livewire\Component;
use Paymenter\Extensions\Others\Onboarding\Models\OnboardingSlide;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Schema;
use App\Helpers\ExtensionHelper;
class Modal extends Component
@@ -16,6 +17,12 @@ class Modal extends Component
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
$extension = ExtensionHelper::getExtension('other', 'Onboarding');
$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
$this->slides = OnboardingSlide::where('enabled', true)
->orderBy('sort', 'asc')
->get()
->toArray();
try {
$this->slides = OnboardingSlide::where('enabled', true)
->orderBy('sort', 'asc')
->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);
}