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

[8.x] Fixes model:prune --pretend command for models with SoftDeletes #39991

Merged
merged 1 commit into from
Dec 12, 2021

Conversation

wgmv
Copy link
Contributor

@wgmv wgmv commented Dec 11, 2021

This PR should fix the model:prune --pretend command when used in combination with soft deleted models.
The withTrashed method is never called because the SoftDeletes class is not found in the array. Therefore the --pretend option always returns 0 when using a condition in the model like

 public function prunable()
    {
        return static::where('deleted_at', '<=', now()->subDays(30));
    }

the query will currently be appended with "where deleted_at is null"

@derekmd
Copy link
Contributor

derekmd commented Dec 11, 2021

A test case should probably be added to tests/Database/PruneCommandTest.php to ensure this works as intended going forward?

@taylorotwell taylorotwell merged commit f3e5cb3 into laravel:8.x Dec 12, 2021
@wgmv wgmv deleted the fixes_database-prune-pretend-command branch December 12, 2021 19:27
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