kadevland/simple-laravel-eloquent-uuid 问题修复 & 功能扩展

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

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

kadevland/simple-laravel-eloquent-uuid

Composer 安装命令:

composer require kadevland/simple-laravel-eloquent-uuid

包简介

A simple Trait provides the ability to use UUID generator in your Eloquent models

README 文档

README

A simple Trait to provide UUID support for your Eloquent models

A simple, automatic UUID generator for any model based on Laravel 7 and above, By using this package when each new entry you will get the following :

  • Generate uuid automatically .
  • Assign it to uuid field in database automatically.
  • easy find it based uuid method.

Installation

You can install the package via Composer:

 composer require kadevland/simple-laravel-eloquent-uuid

Usage

There are two ways to use this package:

  • with uuid in string format Kadevland\Eloquent\Uuid\Traits\HasUuid
  • with uuid in bytes format Kadevland\Eloquent\Uuid\Traits\HasByteUuid

Import trait and set key type string or uuid if use string format.

By default UUID versions is v4

You can also specify v1 UUIDs to be used by setting in config file.

Uuid string format

Models

Use the HasUuid trait:

use Illuminate\Database\Eloquent\Model;
use Kadevland\Eloquent\Uuid\Traits\HasUuid;

class ExampleModel extends Model
{
  use HasUuid;
  
  protected $keyType = 'uuid';
  /* or
  protected $keyType = 'string';
  */       
}

Uuid bytes format

Models

Use the HasByteUuid trait:

use Illuminate\Database\Eloquent\Model;
use Kadevland\Eloquent\Uuid\Traits\HasByteUuid;

class ExampleModel extends Model
{
  use HasByteUuid;

  protected $keyType = 'string';  

}

##Config

You can publish the config file with:

php artisan vendor:publish --provider="kadevland/simple-laravel-eloquent-uuid" --tag="config"

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

License

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

统计信息

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

GitHub 信息

  • Stars: 13
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-05-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固