lopatin96/laravel-referrals

1.0.5 2024-12-06 13:08 UTC

This package is auto-updated.

Last update: 2024-12-06 13:16:24 UTC


README

Trait

Add HasReferrals trait to User model.

use Atin\LaravelReferrals\Traits\HasReferrals;

class User extends Authenticatable
{
    use HasReferrals;

Register the Middleware

Ensure that your HandleReferral middleware is properly registered in the app/Http/Kernel.php file.

protected $middleware = [
    …
    \Atin\LaravelReferrals\Middleware\HandleReferral::class, // Add your middleware here
];

Run Migrations

php artisan migrate

Usage

Now users can get their referral link like this:

{{ auth()->user()->getReferralLink() }}