Skip to content

Commit

Permalink
Merge pull request #218 from plank/fix-delete-offset
Browse files Browse the repository at this point in the history
Fix collection offset access in MediableCollection::delete()
  • Loading branch information
frasmage committed Oct 22, 2020
2 parents 1fa77f2 + 369fbb1 commit 73b8eaf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/MediableCollection.php
Expand Up @@ -114,7 +114,7 @@ public function delete(): void
/** @var MorphToMany $relation */
$relation = $this->first()->media();
$query = $relation->newPivotStatement();
$classes = collect();
$classes = [];

$this->each(function (Model $item) use ($query, $relation, $classes) {
// collect list of ids of each class in case not all
Expand All @@ -132,7 +132,7 @@ public function delete(): void
$query->delete();

// delete each item by class
$classes->each(function (array $ids, string $class) {
collect($classes)->each(function (array $ids, string $class) {
$class::whereIn((new $class)->getKeyName(), $ids)->delete();
});
}
Expand Down

0 comments on commit 73b8eaf

Please sign in to comment.