ddlabs/uuid-package 问题修复 & 功能扩展

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

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

ddlabs/uuid-package

最新稳定版本:2

Composer 安装命令:

composer require ddlabs/uuid-package

包简介

Package to allow you to use UUID for primary key in Laravel Models

README 文档

README

DiegoDev Labs

DiegoLabs UUID Package

Simple package to allow you to add UUID to Laravel Models via a trait.

Install

 composer require ddlabs/uuid-package

Traits

  • SetsUuidWhenCreating - This sets the primary key of the model to a UUID. It allows you to pass a UUID if you have a workflow that creates a UUID by default. If the UUID is version 4 compliant, then the trait will just us the UUID passed to it. We use this from time to time when records are created on a mobile device then passed to a backend via an API. They may already have a UUID associated with it.

Usage

ID must be configured in the database to accept a UUID.

For Migrations:

public function up()
{
    Schema::create('your_models', function (Blueprint $table) {
        $table->uuid('id'); // Set to uuid
        $table->string('name');
        $table->timestamps();
        $table->primary('id'); // Add primary key
    });
}

For Models:

use Ddlabs\Uuid\Traits\SetsUuidWhenCreating;

class YourModel extends Model
{
    use SetsUuidWhenCreating;

    public $incrementing = false;

    protected $keyType = 'string';
   ...
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-03-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固