Skip to content

Commit ea29e20

Browse files
committed
Add check for filament library
1 parent 9ca9f05 commit ea29e20

3 files changed

Lines changed: 18 additions & 5 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"tapp/filament-form-builder": "^4.0"
2121
},
2222
"suggest": {
23-
"tapp/filament-library": "Required for Library file / Library link step materials (enable filament-lms.integrations.filament_library)."
23+
"tapp/filament-library": "Required for Library file / Library link step materials (set filament-lms.integrations.filament_library.enabled for the admin material picker)."
2424
},
2525
"require-dev": {
2626
"filament/upgrade": "^4.0",

resources/views/pages/step.blade.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,18 @@
1919
@if (is_null($step->material_type))
2020
{{-- Intentionally text-only step: show the next button --}}
2121
<x-filament-lms::next-button />
22+
@elseif (in_array($step->material_type, ['library_file', 'library_link'], true) && ! class_exists('Tapp\FilamentLibrary\Models\LibraryItem'))
23+
{{-- Library morph types cannot be resolved without filament-library; avoid loading material() (fatal). --}}
24+
<div class="flex items-center justify-center min-h-[60vh]">
25+
<x-filament::card class="py-12 w-full max-w-md">
26+
<div class="flex flex-col justify-center items-center text-center">
27+
<div class="mb-4 text-lg font-semibold text-red-600">
28+
This step uses library content, but the library package is not installed or unavailable.
29+
</div>
30+
<x-filament-lms::next-button :fixed="false" />
31+
</div>
32+
</x-filament::card>
33+
</div>
2234
@elseif (is_null($step->material))
2335
{{-- Material type is set but material is missing (deleted): show error --}}
2436
<div class="flex items-center justify-center min-h-[60vh]">

src/FilamentLmsServiceProvider.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,10 @@ public function packageBooted()
8585
Livewire::component('view-graded-entry', ViewGradedEntry::class);
8686
Livewire::component('image-step', ImageStep::class);
8787

88-
if (config('filament-lms.integrations.filament_library.enabled', false)
89-
&& class_exists(LibraryItem::class)) {
88+
// Register library step components whenever the optional package is present.
89+
// Config `integrations.filament_library.enabled` only gates admin UI (material picker);
90+
// morph resolution and learner-facing steps must work for existing DB rows even when disabled.
91+
if (class_exists(LibraryItem::class)) {
9092
Livewire::component('library-file-step', LibraryFileStep::class);
9193
Livewire::component('library-link-step', LibraryLinkStep::class);
9294
}
@@ -105,8 +107,7 @@ public function packageBooted()
105107
'image' => 'Tapp\FilamentLms\Models\Image',
106108
];
107109

108-
if (config('filament-lms.integrations.filament_library.enabled', false)
109-
&& class_exists(LibraryItem::class)) {
110+
if (class_exists(LibraryItem::class)) {
110111
$morphMap['library_file'] = LibraryItem::class;
111112
$morphMap['library_link'] = LibraryItem::class;
112113
}

0 commit comments

Comments
 (0)