Skip to content
Browse files

Model::destroy now returns the total number of records deleted.

  • Loading branch information
taylorotwell committed Dec 13, 2013
1 parent 8ab21c2 commit 0f1a3cce2c08cee6fcea5fd754efe54b1130f4db
Showing with 11 additions and 3 deletions.
  1. +9 −2 src/Illuminate/Database/Eloquent/Model.php
  2. +2 −1 src/Illuminate/Foundation/changes.json
@@ -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)
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},

0 comments on commit 0f1a3cc

Please sign in to comment.