承接 gbuckingham89/eloquent-uuid 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

gbuckingham89/eloquent-uuid

最新稳定版本:3.5.0

Composer 安装命令:

composer require gbuckingham89/eloquent-uuid

包简介

A simple package for using UUID's (UUID4) with Laravel's Eloquent.

README 文档

README

A simple package for using UUID's with Laravel's Eloquent models. By including the trait on your models, they will automatically get given a time ordered UUIDv4 for their key (ID) when being persisted to the database.

The current version requires Laravel 5.6 (PHP 7.1) or greater. If you're using an older version of Laravel, please see v1 of this package.

Installation

composer require gbuckingham89/eloquent-uuid

Use

Make sure your database table(s) are setup to handle UUID's. Laravel has a method called uuid() which you can use in your migrations. You will probably want the field to be unique too.

Schema::create('users', function (Blueprint $table) {
    $table->uuid('id')->unique();
    // Other fields here...
});

At the top of your model(s) you simply need to include a trait:

<?php

namespace App;
use Gbuckingham89\EloquentUuid\Traits\UuidForKey;
use Illuminate\Database\Eloquent\Model;

class User extends Eloquent
{
    use UuidForKey;
}

Copyright and license

Code and documentation copyright George Buckingham.

Code released under the MIT License.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-01-16