PHP code example of ozankurt / laravel-modules-loyalty

1. Go to this page and download the library: Download ozankurt/laravel-modules-loyalty 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/ */

    

ozankurt / laravel-modules-loyalty example snippets


// AuthServiceProvider
Gate::define('loyalty:staff', fn ($user) => $user->is_staff);

$program->tiers()->createMany([
    ['threshold' => 3,  'reward' => ['en' => 'Free cookie'],   'position' => 1],
    ['threshold' => 6,  'reward' => ['en' => 'Free coffee'],   'position' => 2],
    ['threshold' => 10, 'reward' => ['en' => 'Free tumbler'],  'position' => 3],
]);

// routes/console.php or the console kernel
Schedule::command('loyalty:expire')->daily();
bash
composer loyalty:install   # publish config, migrations, views, assets
php artisan migrate            # creates loyalty_* tables incl. loyalty_program_tiers + the expiry columns
php artisan loyalty:demo       # seed a program + card, prints the card URL
bash
php artisan loyalty:expire   # schedulable; safe to run repeatedly