'datetime', 'password' => 'hashed']; public function isAdmin(): bool { return $this->role === 'admin'; } public function isChild(): bool { return $this->role === 'child'; } public function attempts() { return $this->hasMany(QuestionAttempt::class); } public function redemptions() { return $this->hasMany(RewardRedemption::class); } public function level(): array { $p = $this->points; if ($p >= 600) return ['label' => 'Meister', 'icon' => '👑', 'color' => 'text-yellow-500', 'next' => null, 'progress' => 100]; if ($p >= 300) return ['label' => 'Wissensprofi', 'icon' => '🌟', 'color' => 'text-purple-500', 'next' => 600, 'progress' => (int)(($p-300)/3)]; if ($p >= 100) return ['label' => 'Lernstar', 'icon' => '⭐', 'color' => 'text-blue-500', 'next' => 300, 'progress' => (int)(($p-100)/2)]; return ['label' => 'Anfänger', 'icon' => '🌱', 'color' => 'text-green-500', 'next' => 100, 'progress' => $p]; } public function currentStreak(): int { $last = $this->attempts()->latest('id')->take(10)->get(); $streak = 0; foreach ($last as $a) { if (!$a->is_correct) break; $streak++; } return $streak; } }