Merge some fix into praguetenniscamp.cz
This commit is contained in:
@@ -22,9 +22,7 @@ trait Content
|
|||||||
$changed = 0;
|
$changed = 0;
|
||||||
|
|
||||||
// check if any file was removed
|
// check if any file was removed
|
||||||
if ($revisionId) {
|
$changed += $this->removeRelatedFiles($revisionId, $assignedFiles);
|
||||||
$changed += $this->removeRelatedFiles($revisionId, $assignedFiles);
|
|
||||||
}
|
|
||||||
|
|
||||||
// allow uploading only on created pages
|
// allow uploading only on created pages
|
||||||
if (!$this->id || !$files[0]) {
|
if (!$this->id || !$files[0]) {
|
||||||
@@ -73,12 +71,10 @@ trait Content
|
|||||||
private function removeRelatedFiles($revisionId, $assignedFiles)
|
private function removeRelatedFiles($revisionId, $assignedFiles)
|
||||||
{
|
{
|
||||||
$allFiles = $this->files()
|
$allFiles = $this->files()
|
||||||
->whereNotIn('id', $assignedFiles)
|
->whereNotIn('id', array_keys($assignedFiles))
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
foreach ($allFiles as $file) {
|
foreach ($allFiles as $file) {
|
||||||
$this->saveHistory($revisionId, 'file', $file->original_filename, ['file' => null]);
|
|
||||||
|
|
||||||
ContentHasFile::where('content_id', $this->id)
|
ContentHasFile::where('content_id', $this->id)
|
||||||
->where('file_id', $file->id)
|
->where('file_id', $file->id)
|
||||||
->delete();
|
->delete();
|
||||||
|
|||||||
Reference in New Issue
Block a user