Download the PHP package assada/laravel-achievements without Composer

On this page you can find all versions of the php package assada/laravel-achievements. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-achievements

Laravel Achievements Logo

Build Status Total Downloads License

An implementation of an Achievement System in Laravel, inspired by Laravel's Notification system.

Table of Contents

  1. Requirements
  2. Installation
  3. Creating Achievements
  4. Unlocking Achievements
  5. Adding Progress
  6. Retrieving Achievements
  7. Event Listeners
  8. License

Requirements

Versions and branches

Installation

Default installation is via Composer.

The service provider will automatically get registered. Or you could add the Service Provider manually to your config/app file in the providers section.

Backup your database and run the migrations in order to setup the required tables on the database.

Creating Achievements

Similar to Laravel's implementation of Notifications, each Achievement is represented by a single class (typically stored in the app\Achievements directory.) This directory will be created automatically for you when you run the make:achievement command.

This command will put a fresh Achievement in your app/Achievements directory with only has two properties defined: name and description. You should change the default values for these properties to something that better explains what the Achievement is and how to unlock it. When you're done, it should look like this:

Unlocking Achievements

Achievements can be unlocked by using the Achiever trait.

This trait contains the unlock method, that can be used to unlock an Achievement. The unlock method expects an Achievement instance:

Remember that you're not restricted to the User class. You may add the Achiever trait to any entity that could unlock Achievements.

Adding Progress

Instead of directly unlocking an achievement, you can add a progress to it. For example, you may have an achievement UserMade10Posts and you want to keep track of how the user is progressing on this Achievement.

In order to do that, you must set an additional parameter on your UserMade10Posts class, called $points:

You may now control the progress by the methods addProgress and removeProgress on the Achiever trait. Both methods expect an Achievement instance and an amount of points to add or remove:

In addition, you can use the methods resetProgress to set the progress back to 0 and setProgress to set it to a specified amount of points:

Once an Achievement reach the defined amount of points, it will be automatically unlocked.

Retrieving Achievements

The Achiever trait also adds a convenient relationship to the entity implementing it: achievements(). You can use it to retrieve progress for all achievements the entity has interacted with. Since achievements() is a relationship, you can use it as a QueryBuilder to filter data even further.

You can also search for a specific achievement using the achievementStatus() method.

There are also three additional helpers on the Achiever trait: lockedAchievements(), inProgressAchievements() and unlockedAchievements().

Event Listeners

Listening to all Achievements

Laravel Achievements provides two events that can be listened to in order to provide "Achievement Unlocked" messages or similar. Both events receive the instance of AchievementProgress that triggered them.

The Assada\Achievements\Event\Progress event triggers whenever an Achiever makes progress, but doesn't unlock an Achievement. The Assada\Achievements\Event\Unlocked event triggers whenever an Achiever actually unlocks an achievement.

Details on how to listen to those events are explained on Laravel's Event documentation.

Listening to specific Achievements

The event listeners mentioned above triggers for all Achievements. If you would like to add an event listener for only a specific Achievement, you can do so by implementing the methods whenUnlocked or whenProgress on the Achievement class.

License

Laravel Achievements is open-sourced software licensed under the MIT license.


All versions of laravel-achievements with dependencies

PHP Build Version
Package Version
Requires ramsey/uuid Version ^3 || ^4
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package assada/laravel-achievements contains the following files

Loading the files please wait ....