承接 jaacu/laravel-model-hashids 相关项目开发

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

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

jaacu/laravel-model-hashids

Composer 安装命令:

composer require jaacu/laravel-model-hashids

包简介

README 文档

README

Latest Version on Packagist Build Status Quality Score Total Downloads StyleCI

Compatible with laravel version 5.8.x

This package allows you to use hashids in your models using the vinkla/laravel-hashids package

This package includes the vinkla/laravel-hashids package

Installation

You can install the package via composer:

composer require jaacu/laravel-model-hashids

Usage

Add to your model migration the following code

...
$table->hashid();
...

Then simply add the UsesHashIds trait to your model

use Jaacu\LaravelModelHashids\Traits\UsesHashIds;

class MyModel extends Model
{
    use UsesHashIds;
}

Now using default laravel routing implicint binding will use the hashid insted of the normal id

Examples

A model using the trait UsesHashIds

$model = Model::first();

Generating url

route('model.show',$model); // output: http://mydomain/model/<hashid>

Getting the hashid

$model->getId() // returns: the model <hashid>

Config

Publish the config file to change default behavior

php artisan vendor:publish --provider="Jaacu\LaravelModelHashids\LaravelModelHashidsServiceProvider"

By default the generated hashid follows this structure: app name + model name + model id hash

  • app name is set by the app.config name and can be overwritten by setting a new 'short_name' in the config/app.php file
  • model name is set by the model class name
  • model hash id is set by the model 'id' hash

This package shares the config file from vinkla/laravel-hashids

In the config/hashids.php you can set the hash length and salt.

'connections' => [
    'main' => [
        'salt' => env('APP_KEY'), // Uses the env app key by default
        'length' => 6,
    ],
    'alternative' => [
        'salt' => 'your-salt-string',
        'length' => 'your-length-integer',
    ],
]

Docs

For more info on the hash functionality see vinkla/laravel-hashids

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email jaacu.97@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-04-20

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固