Skip to content

Commit

Permalink
Remove level method from GiveExperience
Browse files Browse the repository at this point in the history
The method 'level' has been removed from GiveExperience model to reduce complexity. Instead, only 'experience' is now queried in the LeaderboardService to maintain necessary functionality and enhance performance.
  • Loading branch information
cjmellor committed Mar 14, 2024
1 parent 56155e0 commit 899dad5
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 7 deletions.
6 changes: 0 additions & 6 deletions src/Concerns/GiveExperience.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Closure;
use Exception;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Support\Collection;
Expand Down Expand Up @@ -235,9 +234,4 @@ public function levelUp(int $to): void
event(new UserLevelledUp(user: $this, level: $lvl));
}
}

public function level(): BelongsTo
{
return $this->belongsTo(related: Level::class);
}
}
2 changes: 1 addition & 1 deletion src/Services/LeaderboardService.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function __construct()
public function generate(bool $paginate = false, int $limit = null): array|Collection|LengthAwarePaginator
{
return $this->userModel::query()
->with(relations: ['experience', 'level'])
->with(relations: ['experience'])
->orderByDesc(
column: Experience::select('experience_points')
->whereColumn(config('level-up.user.foreign_key'), config('level-up.user.users_table').'.id')
Expand Down

0 comments on commit 899dad5

Please sign in to comment.