existence of attachment must be checked

This commit is contained in:
Sevan Nerse 2021-01-30 21:15:59 +03:00
parent cd42769029
commit 2448943a46

View File

@ -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();
}
}
}