diff --git a/User.php b/User.php deleted file mode 100644 index 0d66728..0000000 --- a/User.php +++ /dev/null @@ -1,57 +0,0 @@ -hasMany(User::class, 'doctor_id'); - } - - // Связь с доктором (если это пациент) - public function doctor() - { - return $this->belongsTo(User::class, 'doctor_id'); - } - // Связь с курсами - public function courses() - { - return $this->belongsToMany(Course::class)->withTimestamps(); - } - - // Связь с упражнениями, с учетом их выполнения - public function exercises() - { - return $this->belongsToMany(Exercise::class, 'exercise_user')->withPivot('completed'); - } - - // Метод для проверки, завершены ли все упражнения - public function isCompleted($userId) - { - // Получаем все упражнения, связанные с курсом - $exercises = $this->exercises; - - // Проверяем, завершены ли все упражнения для данного пациента - foreach ($exercises as $exercise) { - // Проверка завершенности каждого упражнения - $completed = $exercise->users()->wherePivot('user_id', $userId)->wherePivot('completed', true)->exists(); - - if (!$completed) { - return false; // Если хотя бы одно упражнение не завершено - } - } - - return true; // Все упражнения завершены - } - -}