binarycabin/laravel-uuid 问题修复 & 功能扩展

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

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

binarycabin/laravel-uuid

最新稳定版本:1.0.2

Composer 安装命令:

composer require binarycabin/laravel-uuid

包简介

A wrapper for webpatser/laravel-uuid with additional integration

关键字:

README 文档

README

Build Status StyleCI Latest Stable Version Total Downloads

A wrapper for webpatser/laravel-uuid with additional integration

composer require binarycabin/laravel-uuid

This package adds a very simple trait to automatically generate a UUID for your Models.

Simply add the "\BinaryCabin\LaravelUUID\Traits\HasUUID;" trait to your model:

<?php

namespace App;

use BinaryCabin\LaravelUUID\Traits\HasUUID;
use Illuminate\Database\Eloquent\Model;

class Project extends Model
{

    use HasUUID;

}

If your column name is not "uuid", simply add a new property to your model named "uuidFieldName":

protected $uuidFieldName = 'unique_id';

This trait also adds a scope:

\App\Project::byUUID('uuid')->first();

And static find method:

\App\Project::findByUUID('uuid')

A second trait is available if you use your UUIDs as primary keys:

<?php

namespace App;

use BinaryCabin\LaravelUUID\Traits\HasUUID;
use BinaryCabin\LaravelUUID\Traits\UUIDIsPrimaryKey;
use Illuminate\Database\Eloquent\Model;

class Project extends Model
{

    use HasUUID, UUIDIsPrimaryKey;

}

It simply tells Laravel that your primary key isn't an auto-incrementing integer, so it will treat the value correctly.

统计信息

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

GitHub 信息

  • Stars: 86
  • Watchers: 0
  • Forks: 9
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-11-14