questocat/laravel-referral 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

questocat/laravel-referral

最新稳定版本:v1.0.1

Composer 安装命令:

composer require questocat/laravel-referral

包简介

A Referral System With Laravel

README 文档

README

A Referral System With Laravel

StyleCI Scrutinizer Code Quality Build Status Packagist

Installation

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

$ composer require questocat/laravel-referral

First add service providers into the config/app.php

\Questocat\Referral\ReferralServiceProvider::class,

Publish the migrations

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

Publish the config

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

Setup the model

Add UserReferral Trait to your User model.

use Questocat\Referral\Traits\UserReferral

class User extends Model
{
    use UserReferral;
}

Usage

Assigning CheckReferral Middleware To Routes.

// 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:

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

Now you can create the user:

$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:

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

{{ $user->getReferralLink() }}

License

Licensed under the MIT license.

统计信息

  • 总下载量: 81.91k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 140
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 138
  • Watchers: 6
  • Forks: 34
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-04-14