From 22ea2ccc8ffdc348f3a4ad475bc36e4f7ac5c819 Mon Sep 17 00:00:00 2001 From: InsaneTrash Date: Thu, 20 Mar 2025 08:11:10 +0000 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D0=B8=D1=82=D1=8C=20Co?= =?UTF-8?q?urse.php?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Course.php | 42 ------------------------------------------ 1 file changed, 42 deletions(-) delete mode 100644 Course.php diff --git a/Course.php b/Course.php deleted file mode 100644 index 1b1f0f6..0000000 --- a/Course.php +++ /dev/null @@ -1,42 +0,0 @@ -belongsToMany(Exercise::class, 'course_exercise'); - } - public function patients() - { - return $this->belongsToMany(User::class, 'course_patient'); // Связь с пациентами через промежуточную таблицу - } - public function users() - { - return $this->belongsToMany(User::class)->withTimestamps(); - } - public function isCompleted($userId) -{ - // Получаем все упражнения, связанные с курсом - $exercises = $this->exercises; - - // Проверяем, завершены ли все упражнения для данного пользователя - foreach ($exercises as $exercise) { - // Проверка завершенности упражнения для пользователя через связь с таблицей pivot - $completed = $exercise->users()->wherePivot('user_id', $userId)->wherePivot('completed', true)->exists(); - - if (!$completed) { - return false; // Если хотя бы одно упражнение не завершено - } - } - - return true; // Все упражнения завершены -} -}