getspooky/achievements

Laravel Achievements System


Keywords
event, laravel, system, badge, achievements
License
MIT

Documentation

Laravel Achievements System

Achievement is described as a combination of properties (which are counters) guided by simple update and activation rules. When all the properties related to an achievement are active, the achievement is unlocked.

Installation

You can install the package via composer:

composer require getspooky/achievements

Requirements

  • Laravel 5.3 or higher
  • PHP 5.6 or higher

Example

Unlock a new badge when the User has 2 posts :

  • Create a method called dispatchBadge
  • Import Badge\event\BadgeEvent
  • Dispatching Events
  • Render view
 public function dispatchBadge(){
 
       \event(new BadgeEvent([
           "count"=>2
       ]));
 
       return view("welcome");
 
 }

  • Use badge_notify component to display notification , stored in resources/views/components/badge_notify.blade.php
  @component("components.badge_notify",["color"=>"success"])
  
  @endcomponent

Screenshot

Contributors

If you liked the project and want to help, you are welcome! Submit pull requests.

Donate

Paypal

License

MIT license.