定制 lukaskorl/uniquely 二次开发

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

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

lukaskorl/uniquely

Composer 安装命令:

composer require lukaskorl/uniquely

包简介

Uniquely identified models for Laravel 4 by using UUID as primary key

README 文档

README

Uniquely uses UUIDv4 as primary key for Laravel 4 Eloquent models. It automatically generates the UUID when your model is saved. Uniquely overwrites the save() method instead of attaching to Eloquent's creating event in order to circumvent some problems in combination with unit testing.

Installation

To install Uniquely run

$ composer require lukaskorl/uniquely

You can specify 1.* to include the most current version including possible future bugfixes.

Manual installation

If you choose to install Uniquely manually add the following line to your composer.json:

"require": {
    "lukaskorl/uniquely": "1.*"
}

and run

$ composer update

to install the package.

Usage

To use a Uniquely model simply extend your model class from Lukaskorl\Uniquely\Model.

<?php

use Lukaskorl\Uniquely\Model;

class User extends Model {

}

Proper database migrations

The id field of the corresponding database table for your model should be a 36-char string (i.e. VARCHAR(36)). If you are using Laravel 4 migrations you will have to set your id field like so:

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

class CreateUsersTable extends Migration {

	public function up()
	{
		Schema::create('users', function(Blueprint $table)
		{
			$table->string('id', 36);
			// ... other columns ...
			$table->timestamps();
		});

        Schema::table('users', function(Blueprint $table)
        {
            $table->primary('id');
        });
	}


	/**
	 * Reverse the migrations.
	 *
	 * @return void
	 */
	public function down()
	{
		Schema::drop('users');
	}
}

License

Uniquely is open-sourced software licensed under the MIT license.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-07-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固