Skip to content

Commit

Permalink
add getByName() to Achievement class
Browse files Browse the repository at this point in the history
  • Loading branch information
muhammadmp97 committed Dec 10, 2023
1 parent 1004d7d commit 1b053de
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/Console/Commands/UpdateCelebritiesList.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function handle(CreateUserAchievement $createUserAchievement)
->whereIn('followers_count', $topTenFollowersCount)
->get();

$achievement = Achievement::getById(8);
$achievement = Achievement::getByName('celebrity');

UserAchievement::query()
->where('achievement_id', $achievement['id'])
Expand Down
7 changes: 7 additions & 0 deletions app/Services/Achievement.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ public static function getByPassedDays(int $days): ?array
});
}

public static function getByName(string $name): array
{
$achievements = config('hope.achievements');

return Arr::first($achievements, fn ($achievement) => $achievement['name'] === $name);
}

public static function getById(int $id): array
{
return config('hope.achievements')[$id];
Expand Down

0 comments on commit 1b053de

Please sign in to comment.