alihann/laravel-rockid 问题修复 & 功能扩展

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

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

alihann/laravel-rockid

Composer 安装命令:

composer require alihann/laravel-rockid

包简介

Laravel package for id obfuscation using jenssegers/optimus.

README 文档

README

Id obfuscation for Laravel using Optimus.

How to Install

  1. composer require

    composer require alihann/laravel-rockid
  2. in your config/app.php

    'providers' => [
            App\Providers\EventServiceProvider::class,
            App\Providers\RouteServiceProvider::class,
            ...
            Alihann\LaravelRockid\RockidServiceProvider::class,
        ],
  3. and if you want to use facade

    'aliases' => [
            'Validator' => Illuminate\Support\Facades\Validator::class,
            'View' => Illuminate\Support\Facades\View::class,
            ...
            'Rockid' => Alihann\LaravelRockid\Facades\Rockid::class,
        ],
  4. publish the config file

    php artisan vendor:publish
  5. generate numbers and add to the published config file. (i.e. config/rockid.php)

    php artisan rockid:generate

Usage

you can use ObfuscatesId trait to get the obfuscated id of the model in your views.

use Illuminate\Database\Eloquent\Model;
use Alihann\LaravalRockId\ObfuscatesId;

class User extends Model {

  use ObfuscatesId;

}

now you have getId method in your model to generate an obfuscated id.

<a href="user/{{ $user->getId() }}">Show user</a>

routes.php

Route::bind('user', function ($value) {
    $id = Rockid::decode($value);
    return \App\User::find($id);
});

Route::get('user/{user}', function ($user) {
    return $user->getId();
});

or in RouteServiceProvider class

public function boot(Router $router)
{
    parent::boot($router);

    $router->bind('user', function ($value) {
        $id = app('rockid')->decode($value);
        return \App\User::find($id);
    });
}

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-06-01

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固