Add exception for runningInConsole in FilamentFabricatorServiceProvid… #160
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello,
I've encountered an issue with this package, related to using models directly within Block files. The problem arises when these models are loaded from a ServiceProvider. This becomes evident during a fresh migration process, where the error "table not exists" is thrown because the system attempts to access the table while it is being migrated.
To address this issue, I've made modifications to the
FilamentFabricatorServiceProvider
. My approach involves wrapping certain parts of the service provider logic within anif
statement that checks if the application is running in console mode. This ensures that the code within the block doesn't execute when commands are running, thereby preventing the Block files from being called prematurely.Here's the change I've implemented:
With this adjustment, the service provider skips this code when Laravel commands are executed, effectively resolving the migration error without impacting the operational functionality of the package.
I hope this fix can be helpful for others facing the same issue and I believe it could be a valuable addition to the package.
Best regards,
Yolan Mees