1. Go to this page and download the library: Download tankonyako/promocodes 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;
use Illuminate\Notifications\Notifiable;
use Gabievi\Promocodes\Traits\Rewardable;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use Notifiable, Rewardable;
// ...
}
$redeemMessage = $user->redeemCode('ABCD-DCBA', function ($promocode) use ($user) {
return 'Congratulations, ' . $user->name . '! We have added ' . $promocode->reward . ' points on your account';
});
// Congratulations, Zura! We have added 10 points on your account