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,10 +227,12 @@ class Document extends Model
public function delete_attachment() public function delete_attachment()
{ {
foreach ($this->attachment as $file) { if ($attachments = $this->attachment) {
foreach ($attachments as $file) {
MediaModel::where('id', $file->id)->delete(); MediaModel::where('id', $file->id)->delete();
} }
} }
}
/** /**
* Get the discount percentage. * Get the discount percentage.