PHP code example of tlsgroup / laravel-referral

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

    

tlsgroup / laravel-referral example snippets


php artisan vendor:publish --provider="TLSGROUP\LaravelReferral\Providers\ReferralServiceProvider"

 php artisan migrate

use TLSGROUP\LaravelReferral\Traits\Referrable;

class User extends Model
{
    use Referrable;
}

use Illuminate\Support\Facades\Auth;

$user = Auth::user();
$referrer = $user->referralAccount->referrer;

use TLSGROUP\LaravelReferral\Models\Referral;
use Illuminate\Support\Facades\Cookie;

$referralCode = Cookie::get(config('referral.cookie_name'));
$referrer = Referral::userByReferralCode($referralCode);


$user->hasReferralAccount();

$user->createReferralAccount($referrer->id);

$referrals = $user->referrals;

$referralLink = $user->getReferralLink();