Skip to content

Commit

Permalink
fix: Creating new experience issue
Browse files Browse the repository at this point in the history
  • Loading branch information
oktayla committed Jul 28, 2024
1 parent 1db8a0a commit 73e556e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Concerns/GiveExperience.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,14 @@ public function addPoints(
->orderByDesc(column: 'next_level_experience')
->first();

if ($level === null) {
$level = Level::query()
->where(column: 'level', operator: '=', value: config(key: 'level-up.starting_level'))
->first();
}

$experience = $this->experience()->create(attributes: [
'level_id' => $level->level ?? config(key: 'level-up.starting_level'),
'level_id' => $level->id,
'experience_points' => $amount,
]);

Expand Down

0 comments on commit 73e556e

Please sign in to comment.