lopatin96 / laravel-referrals
Laravel blog
Installs: 1 241
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=8.0
Requires (Dev)
- orchestra/testbench: ^8.0
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() }}