承接 lingxi/hashids 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

lingxi/hashids

Composer 安装命令:

composer require lingxi/hashids

包简介

A Hashids bridge for Laravel

README 文档

README

Latest Stable VersionTotal DownloadsLicense

安装

composer require lingxi/hashids

添加到 app.php

Lingxi\Hashids\HashidsServiceProvider::class
'Hashids' => Lingxi\Hashids\Facades\Hashids::class

Config

php artisan vendor:publish --provider='Lingxi\Hashids\HashidsServiceProvider'
<?php

return [

    'default' => 'main',

    'middleware' => [
        'open' => true,

        // 路由中需要被 decode 的 id
        'route_parameters' => [
            //
        ],

        // 请求参数需要被 decode 的 id
        'request_parameters' => [
            //
        ]
    ],

    // 开启严格模式之后,解密 id 错误会抛出异常
    'strict' => [
        'enable' => true,
        'default' => 0,
    ],

    'connections' => [

        'main' => [
            'prefix' => '',
            'salt' => 'your-salt-string',
            'length' => 'your-length-integer',
            'alphabet' => 'your-alphabet-string',
        ],

    ],

];

Middleware

添加中间件

如果是全局中间件,那么对 route 参数是无法自动 decode 的

\Lingxi\Hashids\Middleware\DecodePublicIdMiddleware::class,

在 config/hashids.php 中去配置需要解密的路由参数以及请求参数

Model

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Lingxi\Hashids\ModelTraits\PublicId;

class Post extends Model
{
    use PublicId;

    public function comments()
    {
        return $this->morphMany(\App\Comment::class, 'commentable');
    }
}

Then, get public id.

Post::first()->public_id

Debug

php artisan id:en 1 --uri=p

php artisan id:de sdfghjkla;sdjhasjhdfgahjsdjasd

统计信息

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

GitHub 信息

  • Stars: 18
  • Watchers: 3
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-03-20

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固