Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Gamify Laravel Package

qcod/laravel-gamify

Add gamification to Laravel apps with reputation points and badges. Generate point types via Artisan, award points to users (or any model) using a simple trait, and manage reputations, badges, and user badges with provided migrations and config.

View on GitHub
Deep Wiki
Context7

Getting Started

  1. Install the package: composer require qcod/laravel-gamify
  2. Publish migrations and config:
    php artisan vendor:publish --provider="QCod\Gamify\GamifyServiceProvider" --tag="migrations"
    php artisan vendor:publish --provider="QCod\Gamify\GamifyServiceProvider" --tag="config"
    php artisan migrate
    
  3. Add the Gamify trait to your user/payee model (e.g., App\User)
  4. Start with reputation points:
    php artisan gamify:point PostCreated
    
    Then define payee(), points, and logic in the generated class.

Implementation Patterns

  • Event-driven points: Hook givePoint() into Eloquent events (created, updated, deleted) to automate point awards/revocations.
  • Dynamic point calculation: Override getPoints() instead of using static $points for context-aware rewards (e.g., post length, engagement score).
  • Badge automation: Define badge qualifiers in BadgeType classes—points changes trigger automatic badge checks and assignment.
  • Reputation history: Leverage $user->reputations (a morphMany relation) for audit logs, analytics dashboards, or leaderboard backends.
  • Broadcasting integration: Listen to ReputationChanged events (fire on points update) to push real-time updates via Laravel Echo for live UI feedback.

Gotchas and Tips

  • DBAL requirement: Run composer require doctrine/dbal before running migrations to avoid errors with column modifications.
  • Cache invalidation: After modifying badge definitions, clear badges cache:
    php artisan cache:forget gamify.badges.all
    
  • Duplicate prevention: Set public $allowDuplicates = false in point classes to avoid accidental double-rewarding (e.g., same post edited multiple times).
  • Custom payee logic: Use $payee = 'relation_name' shorthand when the subject model has a direct Eloquent relationship to the payee—avoids boilerplate payee() method.
  • History vs. performance tradeoff: If only total points matter (no history), use HasReputation trait + addPoint()/reducePoint() to skip storing reputation logs.
  • Broadcast channel naming: Ensure frontend listeners use the correct channel prefix (default: user.reputation.{id}) defined in broadcast_on_private_channel and channel_name config.
  • Badge icon paths: Icons must be in badge_icon_folder (default: images/badges/) with badge_icon_extension (default: .svg)—or override with explicit $icon in badge class.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport