From 80beed79965d153bcd95710cb166aede2f758c65 Mon Sep 17 00:00:00 2001 From: Sergey Yarkov Date: Mon, 17 Jan 2022 23:42:30 +0300 Subject: [PATCH] fix: video deleting on update lesson --- app/Repositories/LessonRepository.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Repositories/LessonRepository.ts b/app/Repositories/LessonRepository.ts index e2fc6c3..934ee6e 100644 --- a/app/Repositories/LessonRepository.ts +++ b/app/Repositories/LessonRepository.ts @@ -159,7 +159,10 @@ export default class LessonRepository { /** * Delete video from drive and database */ - await this.Drive.delete(`videos/${lesson.video.name}`); + if (lesson.video) { + await this.Drive.delete(`videos/${lesson.video.name}`); + } + await lesson.related('video').query().delete(); /**