定制 jkbennemann/laravel-external-key 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

jkbennemann/laravel-external-key

Composer 安装命令:

composer require jkbennemann/laravel-external-key

包简介

A simple package to generate Eloquent Model Keys

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Laravel Key Factory is a simple package to generate Eloquent Model Keys for your models easily. This is something I do quite often, instead of using UUID's which can be quite unfriendly to look at, I use Model keys which are unique strings generated for each model.

Installation

You can install the package via composer:

composer require juststeveking/laravel-key-factory

You can publish and run the migrations with:

You can publish the config file with:

php artisan vendor:publish --provider="JustSteveKing\KeyFactory\KeyFactoryServiceProvider" --tag="key-factory-config"

This is the contents of the published config file:

return [
    'key' => [
        'length' => 20,
    ]
];

Usage

This is a very simple to use package. There are two available methods to generate the key:

Using the Key Factory

$key = \JustSteveKing\KeyFactory\KeyFactory::generate(
    prefix: 'test', // what you want to prefix your keys with.
    length: 20, // optional - the default of 20 is set in the config.
);

Using the Str helper

$key = \Illuminate\Support\Str::key(
    prefix: 'test', // what you want to prefix your keys with.
    length: 20, // optional - the default of 20 is set in the config.
);

Eloquent Integration

There is an eloquent model trait available to use called HasKey which will:

When you are creating an eloquent model, the trait will be booted. It will get the first 3 characters of the Model name, force them to lowercase and append a "_" and use this as the prefix for the Key Factory

An example:

  • User Model: use_12345678909876543212
  • Project Model: pro_12345678909876543212

Currently this isn't a configured option as it is easy to override or implement yourself.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-11-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固