From 2448943a4699037392a431f1594ff8fef286d47b Mon Sep 17 00:00:00 2001 From: Sevan Nerse Date: Sat, 30 Jan 2021 21:15:59 +0300 Subject: [PATCH] existence of attachment must be checked --- app/Models/Document/Document.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Models/Document/Document.php b/app/Models/Document/Document.php index 45e56b088..6969acbf0 100644 --- a/app/Models/Document/Document.php +++ b/app/Models/Document/Document.php @@ -227,8 +227,10 @@ class Document extends Model public function delete_attachment() { - foreach ($this->attachment as $file) { - MediaModel::where('id', $file->id)->delete(); + if ($attachments = $this->attachment) { + foreach ($attachments as $file) { + MediaModel::where('id', $file->id)->delete(); + } } }