Added quiz new features

This commit is contained in:
m.razaghi
2026-08-19 12:18:35 +03:30
parent f84ef8c067
commit a6b2a1ba30
11 changed files with 549 additions and 0 deletions

View File

@@ -21,6 +21,9 @@ class User extends Authenticatable
'is_admin',
'email',
'password',
'xp',
'duels_played',
'duels_won',
];
protected $hidden = [
@@ -67,4 +70,25 @@ class User extends Authenticatable
->withPivot('read_at')
->withTimestamps();
}
// ==========================================
// --- NEW: Gamification Relationships ---
// ==========================================
/**
* Get all quest records for the user.
*/
public function userQuests()
{
return $this->hasMany(UserQuest::class);
}
/**
* Helper relationship to quickly get ONLY active, unexpired quests.
*/
public function activeQuests()
{
return $this->hasMany(UserQuest::class)
->where('expires_at', '>', now());
}
}