1. Go to this page and download the library: Download assada/laravel-achievements library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
namespace App\Achievements;
use Assada\Achievements\Achievement;
class UserMadeAPost extends Achievement
{
/*
* The achievement name
*/
public $name = 'Post Created';
/*
* A small description for the achievement
*/
public $description = 'Congratulations! You have made your first post!';
}
namespace App;
use Assada\Achievements\Achiever;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use Achiever;
}
use App\Achievements\UserMadeAPost;
$user->unlock(new UserMadeAPost());
namespace App\Achievements;
use Assada\Achievements\Achievement;
class UserMade10Posts extends Achievement
{
/*
* The achievement name
*/
public $name = '10 Posts Created';
/*
* A small description for the achievement
*/
public $description = 'Wow! You have already created 10 posts!';
/*
* The amount of "points" this user need to obtain in order to complete this achievement
*/
public $points = 10;
}
use App\Achievements\UserMade10Posts;
$user->addProgress(new UserMade10Posts(), 1); // Adds 1 point of progress to the UserMade10Posts achievement
namespace App\Achievements;
use Assada\Achievements\Achievement;
class UserMade50Posts extends Achievement
{
/*
* The achievement name
*/
public $name = '50 Posts Created';
/*
* A small description for the achievement
*/
public $description = 'Wow! You have already created 50 posts!';
/*
* The amount of "points" this user need to obtain in order to complete this achievement
*/
public $points = 50;
/*
* Triggers whenever an Achiever makes progress on this achievement
*/
public function whenProgress($progress)
{
}
/*
* Triggers whenever an Achiever unlocks this achievement
*/
public function whenUnlocked($progress)
{
}
}
bash
php artisan migrate
bash
php artisan make:achievement UserMadeAPost
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.