PHP code example of tizis / laravel-level-system

1. Go to this page and download the library: Download tizis/laravel-level-system 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/ */

    

tizis / laravel-level-system example snippets


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

/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)