diff --git a/app/CMS/Interactions/Admin/Content/EditContent.php b/app/CMS/Interactions/Admin/Content/EditContent.php index b864ea7a..ff68d18f 100644 --- a/app/CMS/Interactions/Admin/Content/EditContent.php +++ b/app/CMS/Interactions/Admin/Content/EditContent.php @@ -61,7 +61,7 @@ class EditContent implements Interaction $this->module->callOnString($page->moduleHandler, 'edit', [$page, $data]); // move to interaction - $keepAssigned = isset($data->keepAssigned) ? $data->keepAssigned : []; + $keepAssigned = isset($data['keepAssigned']) ? $data['keepAssigned'] : []; $page->uploadRelatedFiles($relatedFiles, $keepAssigned); } 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();