### Level Up Configuration Example (PHP) Source: https://github.com/cjmellor/level-up/blob/main/README.md This is an example of the published configuration file for the level-up package. It shows various settings like user foreign key, table names, starting level, multiplier paths, level cap, and audit settings. ```php return [ /* |-------------------------------------------------------------------------- | User Foreign Key |-------------------------------------------------------------------------- | | This value is the foreign key that will be used to relate the Experience model to the User model. | */ 'user' => [ 'foreign_key' => 'user_id', 'model' => App\Models\User::class, ], /* |-------------------------------------------------------------------------- | Experience Table |-------------------------------------------------------------------------- | | This value is the name of the table that will be used to store experience data. | */ 'table' => 'experiences', /* |----------------------------------------------------------------------- | Starting Level |----------------------------------------------------------------------- | | The level that a User starts with. | */ 'starting_level' => 1, /* |----------------------------------------------------------------------- | Multiplier Paths |----------------------------------------------------------------------- | | Set the path and namespace for the Multiplier classes. | */ 'multiplier' => [ 'enabled' => env(key: 'MULTIPLIER_ENABLED', default: true), 'path' => env(key: 'MULTIPLIER_PATH', default: app_path(path: 'Multipliers')), 'namespace' => env(key: 'MULTIPLIER_NAMESPACE', default: 'App\\Multipliers\\'), ], /* |----------------------------------------------------------------------- | Level Cap |----------------------------------------------------------------------- | | Set the maximum level a User can reach. | */ 'level_cap' => [ 'enabled' => env(key: 'LEVEL_CAP_ENABLED', default: true), 'level' => env(key: 'LEVEL_CAP', default: 100), 'points_continue' => env(key: 'LEVEL_CAP_POINTS_CONTINUE', default: true), ], /* | ------------------------------------------------------------------------- | Audit | ------------------------------------------------------------------------- | | Set the audit configuration. | */ 'audit' => [ 'enabled' => env(key: 'AUDIT_POINTS', default: false), ], /* | ------------------------------------------------------------------------- | Record streak history | ------------------------------------------------------------------------- | | Set the streak history configuration. | */ 'archive_streak_history' => [ 'enabled' => env(key: 'ARCHIVE_STREAK_HISTORY_ENABLED', default: true), ], /* | ------------------------------------------------------------------------- | Default Streak Freeze Time | ------------------------------------------------------------------------- | | Set the default time in days that a streak will be frozen for. | */ 'freeze_duration' => env(key: 'STREAK_FREEZE_DURATION', default: 1), ]; ``` -------------------------------- ### Install cjmellor/level-up Package Source: https://github.com/cjmellor/level-up/blob/main/README.md Install the level-up package using Composer. This command fetches and installs the package and its dependencies into your project. ```bash composer require cjmellor/level-up ``` -------------------------------- ### Publish LevelUp Service Provider Configuration and Migrations (PHP/Bash) Source: https://github.com/cjmellor/level-up/blob/main/UPGRADE.md Publishes the configuration file and migration files for the LevelUp package. This is typically done after a new installation or significant update to ensure you have the latest settings and database structures. ```bash php artisan vendor:publish ``` -------------------------------- ### Set Up Levelling Structure (PHP) Source: https://github.com/cjmellor/level-up/blob/main/README.md Shows how to define the experience point requirements for each level using the Level facade. Level 1's 'next_level_experience' should be null, serving as the default starting point. ```php Level::add( ['level' => 1, 'next_level_experience' => null], ['level' => 2, 'next_level_experience' => 100], ['level' => 3, 'next_level_experience' => 250], ); ``` -------------------------------- ### Manage User Experience Points (PHP) Source: https://github.com/cjmellor/level-up/blob/main/README.md Examples of how to add, deduct, set, and retrieve experience points for a user using the `GiveExperience` trait. These methods interact with the `experiences` table. ```php // Add XP points to a User $user->addPoints(10); // Deduct XP points from a User $user->deductPoints(10); // Set XP points to a User (requires existing Experience Model) $user->setPoints(10); // Retrieve a User's points $user->getPoints(); ``` -------------------------------- ### Publish Level-Up Migrations Source: https://github.com/cjmellor/level-up/blob/main/UPGRADE.md Publishes the migration files for the Level Up package. This command is used to bring new database schema changes into your project. ```bash php artisan vendor:publish --tag=level-up-migrations ``` -------------------------------- ### Run Database Migrations (Bash) Source: https://github.com/cjmellor/level-up/blob/main/UPGRADE.md Executes all pending database migrations for the project. This command applies any new table structures or schema modifications defined in the migration files. ```bash php artisan migrate ``` -------------------------------- ### Get Points Until Next Level (PHP) Source: https://github.com/cjmellor/level-up/blob/main/README.md Retrieves the number of experience points a user needs to earn to reach the next level. This method is called on the user model. ```php $user->nextLevelAt(); ``` -------------------------------- ### Handle Gamification Events with PHP Source: https://context7.com/cjmellor/level-up/llms.txt Enables listening to and responding to various gamification events within the application, such as user leveling up, points increasing, achievements being awarded, or streaks being broken. Event listeners are registered in the `EventServiceProvider`, and example listener implementations are provided. ```php use LevelUp\Experience\Events\UserLevelledUp; use LevelUp\Experience\Events\PointsIncreased; use LevelUp\Experience\Events\AchievementAwarded; use LevelUp\Experience\Events\StreakBroken; // Register event listeners in EventServiceProvider protected $listen = [ UserLevelledUp::class => [ SendLevelUpNotification::class, ], PointsIncreased::class => [ CheckAchievementProgress::class, ], AchievementAwarded::class => [ SendAchievementNotification::class, ], StreakBroken::class => [ SendStreakBrokenAlert::class, ], ]; // Example listener implementation class SendLevelUpNotification { public function handle(UserLevelledUp $event): void { $user = $event->user; $level = $event->level; Notification::send($user, new LevelUpNotification($level)); } } ``` -------------------------------- ### Multiplier Qualification Logic (PHP) Source: https://github.com/cjmellor/level-up/blob/main/README.md Example of the 'qualifies' method within a multiplier class. This method contains the conditional logic to determine if the multiplier should be applied. It can check simple conditions like the current month or complex data passed during point addition. ```php public function qualifies(array $data): bool { return now()->month === 12; } ``` ```php public function qualifies(array $data): bool { return isset($data['event_id']) && $data['event_id'] === 222; } ``` -------------------------------- ### Get User's Current Level (PHP) Source: https://github.com/cjmellor/level-up/blob/main/README.md Fetches the current level of a user. This method is called on the user model. ```php $user->getLevel(); ``` -------------------------------- ### Get Current Streak Count (PHP) Source: https://github.com/cjmellor/level-up/blob/main/README.md Retrieves the current streak count for a specific activity associated with a user. ```php $user->getCurrentStreakCount($activity); // 2 ``` -------------------------------- ### Make `ended_at` Nullable in `streak_histories` Table (PHP) Source: https://github.com/cjmellor/level-up/blob/main/UPGRADE.md Modifies the `streak_histories` table to make the `ended_at` column nullable. This involves updating the schema within a Laravel migration file. ```php timestamp('ended_at')->nullable()->change(); }); } public function down(): void { Schema::table('streak_histories', function (Blueprint $table) { $table->dropColumn('ended_at'); }); } }; ``` -------------------------------- ### Publish and Run Level Up Migrations Source: https://github.com/cjmellor/level-up/blob/main/README.md Publish and run the database migrations for the level-up package. This command makes the necessary database tables available for the package's functionality. ```bash php artisan vendor:publish --tag="level-up-migrations" php artisan migrate ``` -------------------------------- ### Generate Leaderboard Source: https://github.com/cjmellor/level-up/blob/main/README.md Demonstrates how to generate a leaderboard using the `Leaderboard` service. This method creates a ranked list of users based on their experience points. ```php Leaderboard::generate(); ``` -------------------------------- ### Publish Level Up Configuration File Source: https://github.com/cjmellor/level-up/blob/main/README.md Publish the configuration file for the level-up package. This allows you to customize package settings according to your project's needs. ```bash php artisan vendor:publish --tag="level-up-config" ``` -------------------------------- ### Run Project Tests (Shell) Source: https://github.com/cjmellor/level-up/blob/main/README.md Command to execute the project's test suite using Composer. ```shell composer test ``` -------------------------------- ### Adding and Managing User Experience Points (PHP) Source: https://context7.com/cjmellor/level-up/llms.txt This snippet demonstrates how to use the `GiveExperience` trait to add, deduct, set, and retrieve experience points for a user. It automatically handles level progression and dispatches events. ```php use LevelUp\Experience\Concerns\GiveExperience; class User extends Model { use GiveExperience; } // Add 50 points to a user $user = User::find(1); $user->addPoints(50); // Deduct points $user->deductPoints(25); // Set points directly (user must have existing experience record) $user->setPoints(100); // Retrieve current points $points = $user->getPoints(); // Returns: 125 ``` -------------------------------- ### Implementing Experience Point Multipliers (PHP) Source: https://context7.com/cjmellor/level-up/llms.txt Learn how to create and apply multipliers to experience points. This includes creating multiplier classes using Artisan and applying them inline or with custom data for conditional point bonuses. ```php // Create a multiplier class using artisan command // php artisan level-up:multiplier IsMonthDecember namespace App\Multipliers; use LevelUp\Experience\Contracts\Multiplier; class IsMonthDecember implements Multiplier { public bool $enabled = true; public function qualifies(array $data): bool { return now()->month === 12; } public function setMultiplier(): int { return 2; // Double points in December } } // Apply multiplier with custom data $user->withMultiplierData(['event_id' => 222]) ->addPoints(10); // Inline conditional multiplier $user->withMultiplierData(fn () => $user->isPremium()) ->addPoints(amount: 10, multiplier: 3); // Manual multiplier without class $user->addPoints(amount: 10, multiplier: 2); // 20 points added ``` -------------------------------- ### Manual Point Multiplication (PHP) Source: https://github.com/cjmellor/level-up/blob/main/README.md Illustrates how to manually apply a multiplier when adding points to a user, bypassing the need for custom multiplier classes or conditional logic within the 'qualifies' method. ```php $user->addPoints( amount: 10, multiplier: 2 ); ``` -------------------------------- ### Create Achievement Model Source: https://github.com/cjmellor/level-up/blob/main/README.md Demonstrates how to create a new achievement using the Achievement model. This involves providing a name, secret status, description, and an image path. ```php Achievement::create([ 'name' => 'Hit Level 20', 'is_secret' => false, 'description' => 'When a User hits Level 20', 'image' => 'storage/app/achievements/level-20.png', ]); ``` -------------------------------- ### Integrate GiveExperience Trait in User Model (PHP) Source: https://github.com/cjmellor/level-up/blob/main/README.md Add the `GiveExperience` trait to your `User` model to enable experience point functionality. This trait provides methods for managing user XP. ```php use LevelUp\Experience\Concerns\GiveExperience; class User extends Model { use GiveExperience; // ... } ``` -------------------------------- ### Record User Activity for Streaks Source: https://github.com/cjmellor/level-up/blob/main/README.md Demonstrates how to record a specific activity for a user to increment their streak count. This involves finding an `Activity` model and then using the `recordStreak` method on the user. ```php $activity = Activity::find(1); $user->recordStreak($activity); ``` -------------------------------- ### Add Points with Auditing Source: https://github.com/cjmellor/level-up/blob/main/README.md Shows how to add experience points to a user while also enabling auditing. The `addPoints` method allows specifying the amount, multiplier, and optional `type` and `reason` for the audit log entry. Auditing must be enabled in the configuration. ```php $user->addPoints( amount: 50, multiplier: 2, type: AuditType::Add->value, reason: "Some reason here", ); ``` -------------------------------- ### Generate Leaderboards with PHP Source: https://context7.com/cjmellor/level-up/llms.txt Creates ranked lists of users based on their experience points. Supports basic generation, pagination, and limiting results to a specific number (e.g., top 10). The response includes user details such as name, experience points, and level. Uses the `Leaderboard` facade. ```php use LevelUp\Experience\Facades\Leaderboard; // Generate basic leaderboard $leaderboard = Leaderboard::generate(); // Generate paginated leaderboard $paginatedLeaderboard = Leaderboard::generate(paginate: true); // Generate limited leaderboard (top 10) $topTen = Leaderboard::generate(limit: 10); // Response structure includes user with experience and level foreach ($topTen as $rank => $user) { echo "{$user->name}: {$user->experience->experience_points} XP - {$user->getLevel()}"; } ``` -------------------------------- ### Configure Level Cap with PHP Source: https://context7.com/cjmellor/level-up/llms.txt Allows setting maximum level limits for users and controlling point accumulation behavior once the cap is reached. Configuration can be done via environment variables (`.env`) or the `config/level-up.php` file. It includes options to enable the level cap, define the maximum level, and determine if users continue to gain points after reaching the cap. ```php // Configure in .env LEVEL_CAP_ENABLED=true LEVEL_CAP=100 LEVEL_CAP_POINTS_CONTINUE=true // Or in config/level-up.php return [ 'level_cap' => [ 'enabled' => true, 'level' => 100, 'points_continue' => true, // Users gain points even at max level ], ]; // Check if user is at level cap if ($user->getLevel() >= config('level-up.level_cap.level')) { echo "Maximum level reached!"; } ``` -------------------------------- ### Managing User Levels and Progression (PHP) Source: https://context7.com/cjmellor/level-up/llms.txt This section details how to define level structures and manage user progression. It covers creating levels, retrieving a user's current level, calculating points needed for the next level, and manually leveling up users. ```php use LevelUp\Experience\Models\Level; // Create level structure Level::add( ['level' => 1, 'next_level_experience' => null], ['level' => 2, 'next_level_experience' => 100], ['level' => 3, 'next_level_experience' => 250], ['level' => 4, 'next_level_experience' => 500], ['level' => 5, 'next_level_experience' => 1000] ); // Get user's current level $currentLevel = $user->getLevel(); // Returns: 3 // Check points needed for next level $pointsNeeded = $user->nextLevelAt(); // Returns: 150 // Get progress as percentage $progressPercent = $user->nextLevelAt(showAsPercentage: true); // Returns: 65 // Manually level up a user $user->levelUp(5); ``` -------------------------------- ### Create a New Multiplier (Artisan Command) Source: https://github.com/cjmellor/level-up/blob/main/README.md Use this Artisan command to generate a new multiplier class. The command creates a PHP file in the specified directory, ready for custom logic. ```bash php artisan level-up:multiplier IsMonthDecember ``` -------------------------------- ### UserLevelledUp Event Data Structure (PHP) Source: https://github.com/cjmellor/level-up/blob/main/README.md Defines the properties available in the UserLevelledUp event, which is dispatched when a user successfully advances to a new level. Includes the user model and the new level achieved. ```php public Model $user, public int $level ``` -------------------------------- ### Passing Extra Data to Multipliers (PHP) Source: https://github.com/cjmellor/level-up/blob/main/README.md Demonstrates how to pass additional data when adding points to a user, which can then be accessed within the 'qualifies' method of a multiplier for more complex conditional checks. ```php $user ->withMultiplierData([ 'event_id' => 222, ]) ->addPoints(10); ``` -------------------------------- ### Creating and Awarding Achievements (PHP) Source: https://context7.com/cjmellor/level-up/llms.txt This snippet illustrates the process of creating achievements, granting them to users with optional progress tracking, incrementing progress, revoking achievements, and retrieving user achievements. It also covers handling secret achievements. ```php use LevelUp\Experience\Concerns\HasAchievements; use LevelUp\Experience\Models\Achievement; class User extends Model { use HasAchievements; } // Create an achievement $achievement = Achievement::create([ 'name' => 'First Blood', 'description' => 'Complete your first task', 'image' => 'storage/achievements/first-blood.png', 'is_secret' => false ]); // Grant achievement to user $user->grantAchievement($achievement); // Grant achievement with progress (0-100%) $user->grantAchievement($achievement, progress: 50); // Increment achievement progress $newProgress = $user->incrementAchievementProgress($achievement, amount: 10); // Revoke an achievement $user->revokeAchievement($achievement); // Retrieve user achievements $achievements = $user->getUserAchievements(); // Get achievements with progress $progressAchievements = $user->achievementsWithProgress()->get(); // Get achievements with specific progress level $highProgress = $user->achievementsWithSpecificProgress(75)->get(); // Work with secret achievements $secretAchievement = Achievement::create([ 'name' => 'Hidden Master', 'is_secret' => true, 'description' => 'Unlock all features' ]); $secretAchievements = $user->secretAchievements; $allAchievements = $user->allAchievements; ``` -------------------------------- ### Track User Streaks with PHP Source: https://context7.com/cjmellor/level-up/llms.txt Manages consecutive daily activities for users, encouraging engagement with automatic streak management. It allows recording activities, checking streak status, and resetting streaks. Dependencies include LevelUp models like Activity and StreakHistory. ```php use LevelUp\Experience\Concerns\HasStreaks; use LevelUp\Experience\Models\Activity; class User extends Model { use HasStreaks; } // Create an activity to track $activity = Activity::create([ 'name' => 'Daily Login', 'description' => 'User logs in daily' ]); // Record a streak activity $user->recordStreak($activity); // Get current streak count $streakCount = $user->getCurrentStreakCount($activity); // Returns: 5 // Check if user has completed streak today $hasStreakToday = $user->hasStreakToday($activity); // Returns: true // Manually reset a streak (archives history if enabled) $user->resetStreak($activity); // Access streak history use LevelUp\Experience\Models\StreakHistory; $history = StreakHistory::where('user_id', $user->id) ->where('activity_id', $activity->id) ->get(); ``` -------------------------------- ### Streak Freeze Duration Configuration (PHP) Source: https://github.com/cjmellor/level-up/blob/main/README.md Configuration setting for the duration of a streak freeze, defaulting to 1 day if not explicitly set in the environment. ```php 'freeze_duration' => env(key: 'STREAK_FREEZE_DURATION', default: 1), ``` -------------------------------- ### Check Achievement Progression Source: https://github.com/cjmellor/level-up/blob/main/README.md Shows how to check the current progression of a user's achievements. `achievementsWithProgress()` retrieves all achievements with their progress, while `achievementsWithSpecificProgress()` filters for achievements with a certain progress amount. ```php $user->achievementsWithProgress()->get(); $user->achievementsWithSpecificProgress(25)->get(); ``` -------------------------------- ### Check User Streak Activity Today (PHP) Source: https://github.com/cjmellor/level-up/blob/main/README.md Verifies if a user has completed the required activity to maintain their streak for the current day. ```php $user->hasStreakToday($activity); ``` -------------------------------- ### View User Audit History Source: https://github.com/cjmellor/level-up/blob/main/README.md Illustrates how to access a user's audit history, which logs their experience point changes. This is done through the `experienceHistory` property on the User model. ```php $user->experienceHistory; ``` -------------------------------- ### Level Cap Configuration (.env variables) Source: https://github.com/cjmellor/level-up/blob/main/README.md Configuration options for the level cap feature, which sets the maximum level a user can reach. These can be controlled via .env variables for enabling the cap, setting the maximum level, and determining if points continue to accrue after hitting the cap. ```env LEVEL_CAP_ENABLED= LEVEL_CAP= LEVEL_CAP_POINTS_CONTINUE ``` -------------------------------- ### Audit Experience Points Changes with PHP Source: https://context7.com/cjmellor/level-up/llms.txt Tracks all changes to user experience points, providing detailed audit trails for analytics and debugging. Allows adding or deducting points with reasons and viewing the user's experience history. Auditing can be enabled/disabled via configuration (`config/level-up.php`). ```php // Enable auditing in config/level-up.php return [ 'audit' => [ 'enabled' => env('AUDIT_POINTS', true), ], ]; // Add points with custom audit info $user->addPoints( amount: 50, multiplier: 2, type: AuditType::Add->value, reason: "Completed premium challenge" ); // Deduct points with reason $user->deductPoints( amount: 25, reason: "Penalty for rule violation" ); // View user's experience history $history = $user->experienceHistory; foreach ($history as $audit) { echo "{$audit->type}: {$audit->points} points - {$audit->reason}"; } ``` -------------------------------- ### Grant and Retrieve User Achievements Source: https://github.com/cjmellor/level-up/blob/main/README.md Illustrates how to grant a specific achievement to a user and how to retrieve all achievements associated with a user. This uses the `grantAchievement` and `getUserAchievements` methods provided by the `HasAchievements` trait. ```php $achievement = Achievement::find(1); $user->grantAchievement($achievement); $user->getUserAchievements(); ``` -------------------------------- ### Integrate HasStreaks Trait Source: https://github.com/cjmellor/level-up/blob/main/README.md Shows how to add the `HasStreaks` trait to your User model to enable streak tracking functionality. This trait is essential for monitoring consecutive daily activities. ```php use LevelUp\Experience\Concerns\HasStreaks; class User extends Model { use HasStreaks; // ... } ``` -------------------------------- ### PointsIncrease Event Data Structure (PHP) Source: https://github.com/cjmellor/level-up/blob/main/README.md Defines the properties available in the PointsIncrease event, which is triggered when experience points are added to a user. Includes details like points added, total points, type, reason, and the user model. ```php public int $pointsAdded, public int $totalPoints, public string $type, public ?string $reason, public Model $user, ``` -------------------------------- ### Add Progress to Achievement Source: https://github.com/cjmellor/level-up/blob/main/README.md Explains how to add progress to an achievement for a user. The `grantAchievement` method can accept a `progress` argument to set the completion percentage, capped at 100%. ```php $user->grantAchievement( achievement: $achievement, progress: 50 // 50% ); ``` -------------------------------- ### Freeze User Streaks with PHP Source: https://context7.com/cjmellor/level-up/llms.txt Allows users to prevent streak loss by freezing their streaks for a specified duration. Streaks can be frozen for a default period (configured in settings) or a custom number of days. It also supports checking if a streak is frozen and manually unfreezing it. Configuration is done via `config/level-up.php`. ```php // Freeze a streak for default duration (1 day from config) $user->freezeStreak(activity: $activity); // Freeze for custom duration $user->freezeStreak(activity: $activity, days: 7); // Check if streak is frozen if ($user->isStreakFrozen($activity)) { echo "Streak is protected!"; } // Unfreeze a streak manually $user->unfreezeStreak($activity); // Configure default freeze duration in config/level-up.php return [ 'freeze_duration' => env('STREAK_FREEZE_DURATION', 1), ]; ``` -------------------------------- ### Conditional Multiplier Inline Callback (PHP) Source: https://github.com/cjmellor/level-up/blob/main/README.md Shows how to implement multiplier conditions inline using a callback function passed to 'withMultiplierData'. This method requires the multiplier to be explicitly set as an argument in the 'addPoints' method. ```php $user ->withMultiplierData(fn () => true) ->addPoints(amount: 10, multiplier: 2); ``` -------------------------------- ### Archive Streak Histories (PHP) Source: https://github.com/cjmellor/level-up/blob/main/README.md Retrieves all archived streak history records. Streaks are archived by default when broken. ```php use LevelUp\Experience\Models\StreakHistory; StreakHistory::all(); ``` -------------------------------- ### Increase Achievement Progression Source: https://github.com/cjmellor/level-up/blob/main/README.md Demonstrates how to increment an achievement's progression for a user using the `incrementAchievementProgress` method. This method allows specifying an amount to increase the progress by, up to a maximum of 100%. An `AchievementProgressionIncreased` event is dispatched. ```php $user->incrementAchievementProgress( achievement: $achievement, amount: 10 ); ``` -------------------------------- ### Freeze User Streak (PHP) Source: https://github.com/cjmellor/level-up/blob/main/README.md Freezes a user's streak for a specified activity. An optional 'days' parameter can set a custom freeze duration. ```php $user->freezeStreak(activity: $activity); $user->freezeStreak(activity: $activity, days: 5); // freeze for 5 days ``` -------------------------------- ### Reset User Streak (PHP) Source: https://github.com/cjmellor/level-up/blob/main/README.md Manually resets a user's streak for a given activity. If archiving is enabled, the streak history will be recorded. ```php $activity = Activity::find(1); $user->resetStreak($activity); ``` -------------------------------- ### Retrieve Secret and All Achievements Source: https://github.com/cjmellor/level-up/blob/main/README.md Shows how to retrieve only the secret achievements a user has unlocked using the `secretAchievements` property, and how to retrieve all achievements (both secret and non-secret) using the `allAchievements` property. ```php $user->secretAchievements; $user->allAchievements; ``` -------------------------------- ### PointsDecreased Event Data Structure (PHP) Source: https://github.com/cjmellor/level-up/blob/main/README.md Defines the properties available in the PointsDecreased event, triggered when experience points are removed from a user. Includes the amount decreased, total points, reason, and the user model. ```php public int $pointsDecreasedBy, public int $totalPoints, public ?string $reason, public Model $user, ``` -------------------------------- ### Mark Achievement as Secret Source: https://github.com/cjmellor/level-up/blob/main/README.md Illustrates how to make an existing achievement secret by updating its `is_secret` attribute to true. Secret achievements are hidden until unlocked. ```php $achievement->update(['is_secret' => true]); ``` -------------------------------- ### StreakUnfrozen Event (PHP) Source: https://github.com/cjmellor/level-up/blob/main/README.md The StreakUnfrozen event is triggered when a streak is unfrozen. No specific data is sent with this event. ```php No data is sent with this event ``` -------------------------------- ### Unfreeze User Streak (PHP) Source: https://github.com/cjmellor/level-up/blob/main/README.md Removes the freeze on a user's streak, allowing it to be broken again if the activity is missed. ```php $user->unfreezeStreak($activity); ``` -------------------------------- ### StreakFrozen Event Properties (PHP) Source: https://github.com/cjmellor/level-up/blob/main/README.md Properties associated with the StreakFrozen event, indicating the length of the frozen streak and its expiration date. ```php public int $frozenStreakLength, public Carbon $frozenUntil, ``` -------------------------------- ### Multiplier Class Structure (PHP) Source: https://github.com/cjmellor/level-up/blob/main/README.md Defines the structure of a multiplier class, implementing the Multiplier contract. It includes an 'enabled' property and 'qualifies' and 'setMultiplier' methods. ```php month === 12; } public function setMultiplier(): int { return 2; } } ``` -------------------------------- ### Check if Streak is Frozen (PHP) Source: https://github.com/cjmellor/level-up/blob/main/README.md Determines if a user's streak for a specific activity is currently in a frozen state. ```php $user->isStreakFrozen($activity); ``` -------------------------------- ### Revoke Achievement from User Source: https://github.com/cjmellor/level-up/blob/main/README.md Demonstrates the process of revoking an achievement from a user using the `revokeAchievement` method. This method handles both standard and secret achievements and dispatches an `AchievementRevoked` event upon successful revocation. ```php $user->revokeAchievement($achievement); ``` -------------------------------- ### StreakBroken Event Properties (PHP) Source: https://github.com/cjmellor/level-up/blob/main/README.md Defines the properties associated with the StreakBroken event, which fires when a user's streak counter is reset. ```php public Model $user, public Activity $activity, public Streak $streak, ``` -------------------------------- ### Integrate HasAchievements Trait Source: https://github.com/cjmellor/level-up/blob/main/README.md Shows how to add the HasAchievements trait to your User model to enable achievement-related functionalities. This trait provides methods for granting, revoking, and managing user achievements. ```php // App\Models\User.php use LevelUp\Experience\Concerns\HasAchievements; class User extends Authenticable { use HasAchievements; // ... } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.