1. Go to this page and download the library: Download famdirksen/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/ */
famdirksen / laravel-referral example snippets
namespace App\Models;
use Famdirksen\LaravelReferral\Contracts\CanReferralContract;
use Famdirksen\LaravelReferral\Traits\CanReferralTrait;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable implements CanReferralContract
{
use CanReferralTrait;
//...
}
namespace App;
use Famdirksen\LaravelReferral\Contracts\HandleReferralContract;
use Famdirksen\LaravelReferral\Traits\HandleReferralTrait;
use Illuminate\Database\Eloquent\Model;
class Order extends Model implements HandleReferralContract
{
use HandleReferralTrait;
//...
}
namespace App\Http;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
class Kernel extends HttpKernel
{
protected $middlewareGroups = [
'web' => [
//...
\Famdirksen\LaravelReferral\Http\Middleware\CheckReferralMiddleware::class,
//...
],
];
//...
}
$user = auth()->user();
// create a referral account for the user
// `name` parameter is used for many type of referral systems
$user->makeReferralAccount('default');
$user = auth()->user();
// get all referralAccounts for the current authenticated user
$referralAccounts = $user->referralAccounts;
// get the default referral account
$defaultReferralAccount = $referralAccounts->first();
// get the referral link for the default referral account
$referralLink = $defaultReferralAccount->getReferralLink();
// get all referrals for a referral account
$referrals = $defaultReferralAccount->referrals->get();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.