Download the PHP package edulazaro/larawards without Composer

On this page you can find all versions of the php package edulazaro/larawards. 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 larawards

Larawards

An way of implementing achievement on Laravel.

How to install Larawards

Execute this command on the Laravel root project folder:

Configure the database details on the .env file and execute the migrations using:

Creating new awards

To create a new award (achievement, trophy, badge...) use this command, replacing FooAchievement for the ward class name:

This will create a new award on the app/Awards/FooAchievement.php.

An award can be of different types, like an achievement or a badge. To set the type, use thje $type attribute:

An award can have one or more tiers. Each tier si something which can be awarded, like an achievement. Tiers allow to define similar achievements on a single file:

Each tier has a title, which is the achievement/badge name and also a score,` which is the score needed to reward the users with the achievement/badge.

Finally, the score method is the place to code the logic which retrieves the current award score for the awardablep user:

Registering awards

If you ant an model to accept rewards, you will need to use the HasWards trait into it, like on this example:

The achievements should be registered with the User model or another model including the HasRewards trait using the AwardProvider:

Or grouped:

Awards can be registed to any model which uses the HasRewards trait.

Checking rewards

When you need to check an award, you can do this:

As you can see, the award needs to be scoped first to the user This will add the reward if it matches the requirement of any tier. awardables.

You can also perform queries to check many awards at a time. This will check all awards assigned to a user:

You can also select a specific group:

Or a specific type:

Once an award is awarded, it will be added into the rewards table.

Reward events

If you want, you can specify an event to be fired using the $event attribute:

This event will be fired each time a user gets a reward.

Checking awards

To get the rewards for a user you can do:

To check if a specific award and tier has been rewarded:

You can query the rewards for many users:

Awards morph map

This works in the same way as the standard Laravel morph maps.

When a reward is inserte dinto the database, the award id will be the class where the award is defined. However this looks ugly. To fix it, use the Award::enforceMap method on any service provider:

This will assign the specified alias to the desided Award classes. For example, the App\Awards\CommentsAchievement will be represented as comments_achievement which is more readable.

License

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


All versions of larawards with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
laravel/framework Version >=9
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 edulazaro/larawards contains the following files

Loading the files please wait ....