diff --git a/app/Models/Content/ModelTraits/Content.php b/app/Models/Content/ModelTraits/Content.php index d983a346..6b4a8206 100644 --- a/app/Models/Content/ModelTraits/Content.php +++ b/app/Models/Content/ModelTraits/Content.php @@ -22,9 +22,7 @@ trait Content $changed = 0; // check if any file was removed - if ($revisionId) { - $changed += $this->removeRelatedFiles($revisionId, $assignedFiles); - } + $changed += $this->removeRelatedFiles($revisionId, $assignedFiles); // allow uploading only on created pages if (!$this->id || !$files[0]) { @@ -73,12 +71,10 @@ trait Content private function removeRelatedFiles($revisionId, $assignedFiles) { $allFiles = $this->files() - ->whereNotIn('id', $assignedFiles) + ->whereNotIn('id', array_keys($assignedFiles)) ->get(); foreach ($allFiles as $file) { - $this->saveHistory($revisionId, 'file', $file->original_filename, ['file' => null]); - ContentHasFile::where('content_id', $this->id) ->where('file_id', $file->id) ->delete();