Added Notifications
This commit is contained in:
@@ -41,6 +41,26 @@ class User extends Authenticatable
|
||||
return $this->hasMany(UserAchievement::class);
|
||||
}
|
||||
|
||||
public function unlockedAchievements(): HasMany
|
||||
{
|
||||
return $this->achievements()
|
||||
->join('achievements', 'achievements.id', '=', 'user_achievements.achievement_id')
|
||||
->where(function ($query) {
|
||||
$query
|
||||
// Non-progressive achievements: always count
|
||||
->where(function ($q) {
|
||||
$q->where('achievements.progressive', false)
|
||||
->orWhereNull('achievements.progressive');
|
||||
})
|
||||
// Progressive achievements: only if progress >= threshold
|
||||
->orWhere(function ($q) {
|
||||
$q->where('achievements.progressive', true)
|
||||
->whereNotNull('achievements.threshold')
|
||||
->whereColumn('user_achievements.progress', '>=', 'achievements.threshold');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public function resolveRouteBinding($value, $field = null): ?User
|
||||
{
|
||||
return $this->where('name', 'ilike', $value)->firstOrFail();
|
||||
|
||||
Reference in New Issue
Block a user