Skip to content

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