PHP code example of asciisd / referrals-laravel

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

    

asciisd / referrals-laravel example snippets


class User extends Authenticatable implements MustVerifyEmail{
     /*...*/
     use \Asciisd\ReferralsLaravel\app\Traits\Referrerable;
     /*...*/
 
}

protected $middlewareAliases = [
    /*...*/
    'referrals' => \Asciisd\ReferralsLaravel\app\Http\Middleware\ReferralsLaravel::class,
];

protected $middlewareGroups = [
        'web' => [
            /*...*/
            \Asciisd\ReferralsLaravel\app\Http\Middleware\ReferralsLaravel::class,
        ],
        /*...*/
]

foreach ($user->referrals as $referral)
{
    $referral->referral_token;
}

// Get authenticated referral token
auth()->user()->referral->referral_token;

// Return true if the user is invited
// and false if the user was not invited by other user.
$user->isReferred();

// Return true if the user has referral token, or false if not.
$user->hasReferralToken();

$user->generateReferralToken();

protected $append = ['referral_link'];

// Get the referral link with the user redirect route
// ex: https://mydomain.com/register?ref=34532234
$user->getReferralLink();

protected $append = ['referral_token'];

$user->getReferralToken();

$ php artisan vendor:publish