定制 mindtwo/laravel-auto-create-uuid 二次开发

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

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

mindtwo/laravel-auto-create-uuid

最新稳定版本:2.6.4

Composer 安装命令:

composer require mindtwo/laravel-auto-create-uuid

包简介

Laravel Auto Create UUID

README 文档

README

Build Status StyleCI Quality Score Latest Stable Version Total Downloads MIT Software License

Installation

You can install the package via composer:

composer require mindtwo/laravel-auto-create-uuid

How to use?

Prepare eloquent model

Simply use the AutoCreateUuid trait in your eloquent model.

namespace example;

use Illuminate\Database\Eloquent\Model;
use mindtwo\LaravelAutoCreateUuid\AutoCreateUuid;

class Example extends Model
{
    use AutoCreateUuid;
}

Add UUID column to migration

Make sure to add the column in your migration file.

$table->string('uuid', 36)->unique();

Customize UUID attribute

The default attribute name for the auto generated UUID is 'uuid'. However you can customize it, if you need. There are two possibilities to do so.

Either you set up a property named 'uuid_column':

namespace example;

use Illuminate\Database\Eloquent\Model;
use mindtwo\LaravelAutoCreateUuid\AutoCreateUuid;

class Example extends Model
{
    use AutoCreateUuid;
    
    protected $uuid_column = 'id'
}

or you overload the getUuidColumn() method:

namespace example;

use Illuminate\Database\Eloquent\Model;
use mindtwo\LaravelAutoCreateUuid\AutoCreateUuid;

class Example extends Model
{
    use AutoCreateUuid;
    
    /**
     * Get the column name for uuid attribute.
     *
     * @return string
     */
    public function getUuidColumn(): string
    {
        return 'id';
    }
}

In both cases the attribute name for the UUID is now 'id' instead of 'uuid'.

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 info@mindtwo.de instead of using the issue tracker.

Credits

License

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-12-04