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; // Все упражнения завершены -} -}