From 6e1dcd9d1c2474bbb89b189a01f7d90626acbdf8 Mon Sep 17 00:00:00 2001 From: arslandevelopments Date: Wed, 19 Aug 2026 13:55:51 +0200 Subject: [PATCH] =?UTF-8?q?comments=20in=20models=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/Habit.php | 3 ++- app/Models/User.php | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) mode change 100644 => 100755 app/Models/Habit.php mode change 100644 => 100755 app/Models/User.php diff --git a/app/Models/Habit.php b/app/Models/Habit.php old mode 100644 new mode 100755 index 63f073c..f867d45 --- a/app/Models/Habit.php +++ b/app/Models/Habit.php @@ -49,6 +49,7 @@ class Habit return $habit ?: null; } + // Legt einen neuen Habit an public static function create(int $userId, array $data): bool { $sql = 'INSERT INTO habits (user_id, category_id, title, description, target_per_week) @@ -111,4 +112,4 @@ class Habit $insert = $db->prepare('INSERT INTO habit_logs (habit_id, completed_on) VALUES (:habit_id, CURRENT_DATE)'); return $insert->execute(['habit_id' => $id]); } -} +} \ No newline at end of file diff --git a/app/Models/User.php b/app/Models/User.php old mode 100644 new mode 100755 index 32e57d2..eaa8bd5 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -2,6 +2,7 @@ class User { + // Legt einen neuen Benutzer an public static function create(string $name, string $email, string $password): bool { $sql = 'INSERT INTO users (name, email, password_hash) VALUES (:name, :email, :password_hash)'; @@ -14,6 +15,7 @@ class User ]); } + // Sucht einen Benutzer anhand der E-Mail public static function findByEmail(string $email): ?array { $statement = Database::connection()->prepare('SELECT * FROM users WHERE email = :email LIMIT 1'); @@ -22,4 +24,4 @@ class User $user = $statement->fetch(); return $user ?: null; } -} +} \ No newline at end of file