From 770cf0cf81c6b57b58005b920d9d27ace6066177 Mon Sep 17 00:00:00 2001 From: Matthias Nagel Date: Thu, 6 Jan 2022 17:19:39 +0100 Subject: [PATCH] Fixed order of deletion. --- src/NodeTrait.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/NodeTrait.php b/src/NodeTrait.php index 0b985ab..13eb0c6 100644 --- a/src/NodeTrait.php +++ b/src/NodeTrait.php @@ -49,10 +49,9 @@ public static function bootNodeTrait() static::deleting(function ($model) { // We will need fresh data to delete node safely + // We must delete the descendants BEFORE we delete the actual + // album to avoid failing FOREIGN key constraints. $model->refreshNode(); - }); - - static::deleted(function ($model) { $model->deleteDescendants(); });