Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Model::destroy now returns the total number of records deleted.
- Loading branch information
|
@@ -884,10 +884,15 @@ public function joiningTable($related) |
|
|
* Destroy the models for the given IDs. |
|
|
* |
|
|
* @param array|int $ids |
|
|
* @return void |
|
|
* @return int |
|
|
*/ |
|
|
public static function destroy($ids) |
|
|
{ |
|
|
// We'll initialize a count here so we will return the total number of deletes |
|
|
// for the operation. The developers can then check this number as a boolean |
|
|
// type value or get this total count of records deleted for logging, etc. |
|
|
$count = 0; |
|
|
|
|
|
$ids = is_array($ids) ? $ids : func_get_args(); |
|
|
|
|
|
$instance = new static; |
|
@@ -899,8 +904,10 @@ public static function destroy($ids) |
|
|
|
|
|
foreach ($instance->whereIn($key, $ids)->get() as $model) |
|
|
{ |
|
|
$model->delete(); |
|
|
if ($model->delete()) $count++; |
|
|
} |
|
|
|
|
|
return $count; |
|
|
} |
|
|
|
|
|
/** |
|
|
|
@@ -68,7 +68,8 @@ |
|
|
{"message": "Added pessimistic locking to query builder via 'lock', 'lockForUpdate', and 'sharedLock'.", "backport": null}, |
|
|
{"message": "Closure can now be passed to Collection->first, functions similarly to array_first.", "backport": null}, |
|
|
{"message": "Added Mail::failures to get the failed recipients for a message.", "backport": null}, |
|
|
{"message": "Renamed `Model::tags($cacheTags)` to `Model::cacheTags($cacheTags)`", "backport": null} |
|
|
{"message": "Renamed `Model::tags($cacheTags)` to `Model::cacheTags($cacheTags)`", "backport": null}, |
|
|
{"message": "Model::destroy now returns the total number of records deleted.", "backport": null} |
|
|
], |
|
|
"4.0.x": [ |
|
|
{"message": "Added implode method to query builder and Collection class.", "backport": null}, |
|
|