hinet/laravel-invitecode

invite code for laravel

1.0.8 2022-02-19 02:25 UTC

This package is auto-updated.

Last update: 2024-04-29 10:28:19 UTC


README

Invit code extend package for laravel, generates invite code using user ID and decodes user ID according to the invite code. It supports custom defined invite code with fixed length
基于Laravel的邀请码扩展包,使用用户ID生成邀请码,并可根据邀请码解码出用户ID,支持自定义邀请码固定长度。

安装

composer require hinet/laravel-invitecode

配置

php artisan vendor:publish --tag=invitecode

修改config/invitecode.php自定义你的配置

return   [
    'length' => 6, //邀请码长度
    'char' => '',//生成邀请码的字符,默认a-zA-Z0-9
    'salt' => '',//加密盐,默认使用APP_KEY
];

使用示例

namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use InviteCode;
class DemoController extends Controller{
    public function index(){
        echo InviteCode::enCode(123);
        //print NDZ0kA
        //echo echo InviteCode::deCode('NDZ0kA');
        //print 123
    }
}