2017 © Pedro Peláez
 

library laravel-referral

A Referral System With Laravel

image

questocat/laravel-referral

A Referral System With Laravel

  • Sunday, May 27, 2018
  • by questocat
  • Repository
  • 1 Watchers
  • 1 Stars
  • 78 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 388 % Grown

The README.md

laravel-referral

A Referral System With Laravel, (*1)

StyleCI Scrutinizer Code Quality Build Status Packagist, (*2)

Installation

Via Composer to add the package to your project's dependencies:, (*3)

$ composer require questocat/laravel-referral

First add service providers into the config/app.php, (*4)

\Questocat\Referral\ReferralServiceProvider::class,

Publish the migrations, (*5)

$ php artisan vendor:publish --provider="Questocat\Referral\ReferralServiceProvider" --tag="migrations"

Publish the config, (*6)

$ php artisan vendor:publish --provider="Questocat\Referral\ReferralServiceProvider" --tag="config"

Setup the model

Add UserReferral Trait to your User model., (*7)

use Questocat\Referral\Traits\UserReferral

class User extends Model
{
    use UserReferral;
}

Usage

Assigning CheckReferral Middleware To Routes., (*8)

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

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

Once the middleware has been defined in the HTTP kernel, you may use the middleware method to assign middleware to a route:, (*9)

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

Now you can create the user:, (*10)

$user = new App\User();
$user->name = 'zhengchaopu';
$user->password = bcrypt('password');
$user->email = 'zhengchaopu@gmail.com';
$user->save();

// Or

$data = [
    'name' => 'zhengchaopu',
    'password' => bcrypt('password'),
    'email' => 'zhengchaopu@gmail.com',
];

App\User::create($data);

Get the referral link:, (*11)

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

{{ $user->getReferralLink() }}

License

Licensed under the MIT license., (*12)

The Versions

27/05 2018

dev-master

9999999-dev

A Referral System With Laravel

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Avatar questocat

referral affiliate-tracking referral-system

14/04 2018

v1.0.0

1.0.0.0

A Referral System With Laravel

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Avatar questocat

referral affiliate-tracking referral-system