Your Assignment
Unlocking Achievements
You need to write the code that listens for user events and unlocks the relevant achievement.
For example;
• When a user writes a comment for the first time they unlock the “First Comment Written” achievement.
• When a user has already unlocked the “First Lesson Watched” achievement by watching a single video and then watches another four videos they unlock the “5 Lessons Watched” achievement.
AchievementUnlocked Event
When an achievement is unlocked an AchievementUnlocked event must be fired with a payload of;
achievement_name (string) user (User Model)
BadgeUnlocked Event
When a user unlocks enough achievement to earn a new badge a BadgeUnlocked event must be fired with a payload of;
badge_name (string) user (User Model)
Achievements Endpoint
There is an endpoint users/{user}/achievements
that can be found in the ‘web’ routes file, this must return the following;
unlocked_achievements (string[ ]) An array of the user’s unlocked achievements by name
next_available_achievements (string[ ]) An array of the next achievements the user can unlock by name.
Note: Only the next available achievement should be returned for each group of achievements.
Example: If the user has unlocked the “5 Lessons Watched” and “First Comment Written” achievements only the “10 Lessons Watched” and “3 Comments Written“ achievements should be returned.
current_badge (string) The name of the user’s current badge.
- git clone or zip download
- composer install
- set .evn
- To run all tests
clear && vendor/bin/phpunit
- To run tests by name
clear && vendor/bin/phpunit --filter test_name
- Api endpoints can be consumed from route/api.php
- php artisan migrate:fresh --seed
- php artisan serve
- visit http://127.0.0.1:8000/users/4/achievements 10 view response.