Merge some fix into praguetenniscamp.cz

This commit is contained in:
Michal Kváček
2017-02-23 18:26:43 +01:00
+2 -6
View File
@@ -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();