定制 konstantinkoslow/laravel-uuid 二次开发

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

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

konstantinkoslow/laravel-uuid

Composer 安装命令:

composer require konstantinkoslow/laravel-uuid

包简介

UUID primary key for Laravel Eloquent Models.

README 文档

README

Trait for generating UUID primary keys for Laravel version 5.6 and higher.

Installation

Install the package via Composer:

composer require konstantinkoslow/laravel-uuid

Usage

Laravel Migrations

To let a Model make use of UUIDs as primary key, you have to add a UUID field in your migration file and set this as primary key:

Schema::create('table_name', function (Blueprint $table) {
    $table->uuid('id');
    $table->primary('id');

    // or

    $table->char('key', 36)->primary();
});

Eloquent will also assume that each table has a primary key column named id. You may define a protected $primaryKey property to override this convention.

For example:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class ModelName extends Model
{
    protected $primaryKey = 'key';
}

Read more Laravel - Eloquent Model Conventions.

Eloquent Model

Bind the traid with the use operator into the Model that uses UUIDs as primary key:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use KonstantinKoslow\LaravelUuid\UsesUuid;

class ModelName extends Model
{
    use UsesUuid;
}

License

Laravel UUID is licensed under the MIT license.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-12-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固