PHP code example of questocat / laravel-referral

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

    

questocat / laravel-referral example snippets


\Questocat\Referral\ReferralServiceProvider::class,

use Questocat\Referral\Traits\UserReferral

class User extends Model
{
    use UserReferral;
}

// Within App\Http\Kernel Class...

protected $routeMiddleware = [
    'referral' => \Questocat\Referral\Http\Middleware\CheckReferral::class,
];

Route::get('/', 'HomeController@index')->middleware('referral');

$user = new App\User();
$user->name = 'zhengchaopu';
$user->password = bcrypt('password');
$user->email = '[email protected]';
$user->save();

// Or

$data = [
    'name' => 'zhengchaopu',
    'password' => bcrypt('password'),
    'email' => '[email protected]',
];

App\User::create($data);

$user = App\User::findOrFail(1);

{{ $user->getReferralLink() }}