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] Add support to Eloquent Collection on Model::destroy() #36497

Merged
merged 1 commit into from
Mar 8, 2021
Merged

[8.x] Add support to Eloquent Collection on Model::destroy() #36497

merged 1 commit into from
Mar 8, 2021

Conversation

vdauchy
Copy link
Contributor

@vdauchy vdauchy commented Mar 8, 2021

Hi,

Currently doing SomeModel::destroy(SomeModel::all()) will do nothing which to me was unexpected.
This is due to the fact that destroy() takes any Collection as a list of ids which is fine if we do :

SomeModel::destroy(SomeModel::all()->pluck('whatever_primary_key'))
or
SomeModel::destroy(SomeModel::all()->modelKeys())

This PR will apply the second solution if an EloquentCollection is passed and keep the current behavior for BaseCollection.

@itxshakil
Copy link

itxshakil commented Mar 8, 2021

I guess, It should be merged as it is intended behavior.

@driesvints driesvints changed the title Add support to Eloquent Collection on Model::destroy() [8.x] Add support to Eloquent Collection on Model::destroy() Mar 8, 2021
@taylorotwell taylorotwell merged commit f1b17a2 into laravel:8.x Mar 8, 2021
This was referenced Mar 10, 2021
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