Skip to content
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

Call relationship directly to allow deletes with lazy loading disabled #50

Conversation

lukasleitsch
Copy link
Contributor

Laravel allows disabling lazy loading in the entire project.

// app/Providers/AppServiceProvider.php
 
public function boot()
{
    Model::preventLazyLoading(! app()->isProduction());
}

More about this feature: https://laravel-news.com/disable-eloquent-lazy-loading-during-development

With this feature enabled deleting of nested relationships is not working.

Calling the relationship directly and not via the property solves this issue.

src/CascadeSoftDeletes.php Outdated Show resolved Hide resolved
@michaeldyrynda michaeldyrynda merged commit f961920 into michaeldyrynda:main Jan 5, 2022
@michaeldyrynda
Copy link
Owner

Thanks @lukasleitsch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants