Looking to hire Laravel developers? Try LaraJobs

laravel-level-system maintained by tizis

Last update
2021/09/03 15:34 (dev-main)
License
Links
Downloads
306

Comments
comments powered by Disqus

Install

composer require tizis/laravel-level-system

Publish Migrations & migrate

php artisan vendor:publish --provider="tizis\LevelSystem\Providers\ServiceProvider" --tag=migrations
php artisan migrate //adding level & experience columns into 'users' table

Publish Config & configure

php artisan vendor:publish --provider="tizis\LevelSystem\Providers\ServiceProvider" --tag=config

Example

/config/user-levels.php

return [
    'levels' => [
        1 => 100,
        2 => 200,
        3 => 300,
        4 => 400,
        5 => 500,
        ...
    ]
];
$user = User::where('id', 1)->first();
$service = new LevelService($user);  
$service->addProgress(500); // now user has 2nd level and 200 points of experience (500 - 100 - 200)