webazin/referral

A Referral system for Laravel application

dev-main 2024-01-05 07:01 UTC

This package is auto-updated.

Last update: 2024-05-05 07:39:32 UTC


README

A Referral System With Laravel

Installation

Via Composer to add the package to your project's dependencies:

composer require "webazin/referral @dev"

migrations

 php artisan migrate

Setup the model

Add ReferralTrait Trait to your User model.

use Webazin\Referral\ReferralTrait

class User extends Model
{
    use ReferralTrait;
}

Params

App\User::find(1)->getRefLink();

App\User::find(1)->setParentId($referralCode);
App\User::find(1)->getParent();

App\User::find(1)->setReferralCode();
// if this set --- set parent id 
App\User::find(1)->getReferralCodeFromCookie();

//relationships
App\User::find(1)->parent;
App\User::find(1)->child;

App\User::find(1)->referralCount();

License

Licensed under the MIT license.