From b12bacf035b2c1c06b9b4cb5941f2781a4941946 Mon Sep 17 00:00:00 2001 From: InsaneTrash Date: Thu, 20 Mar 2025 08:11:19 +0000 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D0=B8=D1=82=D1=8C=20Us?= =?UTF-8?q?er.php?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- User.php | 57 -------------------------------------------------------- 1 file changed, 57 deletions(-) delete mode 100644 User.php 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; // Все упражнения завершены - } - -}