-
Notifications
You must be signed in to change notification settings - Fork 3
Allow nullable material on step #87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is ON. A Cloud Agent has been kicked off to fix the reported issues.
- Bug 1: In step.blade.php, distinguish between intentionally text-only steps
(material_type is null) and steps with deleted material (material_type is set
but material record doesn't exist). Now shows error for deleted material
regardless of whether text exists.
- Bug 2: In MorphToSelectWithCreate.php, change material_id from nullable() to
requiredWith('material_type') to prevent invalid state where material_type is
selected but material_id is null.
|
Bugbot Autofix prepared a fix for 2 of the 2 bugs found in the latest run.
Or push these changes by commenting: Preview (d2b7e39a1c)diff --git a/resources/views/pages/step.blade.php b/resources/views/pages/step.blade.php
--- a/resources/views/pages/step.blade.php
+++ b/resources/views/pages/step.blade.php
@@ -111,23 +111,21 @@
}
</style>
- @if (is_null($step->material))
- @if(!$step->text)
- {{-- No material and no text: show error --}}
- <div class="flex items-center justify-center min-h-[60vh]">
- <x-filament::card class="py-12 w-full max-w-md">
- <div class="flex flex-col justify-center items-center text-center">
- <div class="mb-4 text-lg font-semibold text-red-600">
- The material for this step is missing or has been deleted.
- </div>
- <x-filament-lms::next-button :fixed="false" />
+ @if (is_null($step->material_type))
+ {{-- Intentionally text-only step: show the next button --}}
+ <x-filament-lms::next-button />
+ @elseif (is_null($step->material))
+ {{-- Material type is set but material is missing (deleted): show error --}}
+ <div class="flex items-center justify-center min-h-[60vh]">
+ <x-filament::card class="py-12 w-full max-w-md">
+ <div class="flex flex-col justify-center items-center text-center">
+ <div class="mb-4 text-lg font-semibold text-red-600">
+ The material for this step is missing or has been deleted.
</div>
- </x-filament::card>
- </div>
- @else
- {{-- Text-only step: show the next button --}}
- <x-filament-lms::next-button />
- @endif
+ <x-filament-lms::next-button :fixed="false" />
+ </div>
+ </x-filament::card>
+ </div>
@elseif ($step->material_type == 'video')
<livewire:video-step :step="$step"/>
@elseif ($step->material_type == 'form')
diff --git a/src/Forms/Components/MorphToSelectWithCreate.php b/src/Forms/Components/MorphToSelectWithCreate.php
--- a/src/Forms/Components/MorphToSelectWithCreate.php
+++ b/src/Forms/Components/MorphToSelectWithCreate.php
@@ -62,7 +62,7 @@
return $className::query()->pluck('name', 'id');
})
->searchable()
- ->nullable()
+ ->requiredWith('material_type')
->suffixActions([
Action::make('create_video')
->label('New') |
|
Could not push Autofix changes. The PR branch may have changed since the Autofix ran, or the Autofix commit may no longer exist. |
…ncy-8a6f Step material consistency
|
Scott is good with this approach |

Details
Allow nullable material on step.
Note
Medium Risk
Includes a schema change to nullable morph columns and corresponding UI/runtime behavior changes; risk is mainly around migration compatibility and ensuring existing steps still render/validate as expected.
Overview
Steps can now be created without an attached material (text-only steps).
This adds a migration to make
lms_steps.material_typeandmaterial_idnullable and wires it into the package migrations list, updates the material selector form to allow a nullmaterial_typewhile only requiringmaterial_idwhen a type is chosen, and adjusts the step page to treatmaterial_type = nullas an intentional “next-only” step while still showing an error when a type is set but the related material record is missing. TheStepFactorygainswithoutMaterial()andwithText()helpers, and theStepmodel phpdoc is updated for nullable material fields.Written by Cursor Bugbot for commit cd81152. This will update automatically on new commits. Configure here.