chistel/laravel-uniqueid 问题修复 & 功能扩展

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

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

chistel/laravel-uniqueid

Composer 安装命令:

composer require chistel/laravel-uniqueid

包简介

Generate uniqueid when saving Eloquent models to be used as auth key and route key

README 文档

README

but the difference is that it's meant to use unique string for model routes.

Installation

You can install the package via composer:

composer require chistel/laravel-uniqueid

Usage

Your Eloquent models should use the Chistel\LaravelUniqueId\HasUniqueId trait and the Chistel\LaravelUniqueId\UniqueIdOptions class.

The trait contains an abstract method getUniqueIdOptions() that you must implement yourself.

Here's an example of how to implement the trait:

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Chistel\LaravelUniqueId\HasUniqueId;
use Chistel\LaravelUniqueId\UniqueIdOptions;

class UserModel extends Model
{
   use HasUniqueId;
    
   /**
	 * Get the route key for the model.
	 *
	 * @return string
	 */
	public function getRouteKeyName()
	{
	    return 'user_unique_id';  // this is the unique key column 
	}
	/**
	* Get the options for generating model uniqueId.
	*/
	public function getUniqueIdOptions() : UniqueIdOptions
	{
	  	return UniqueIdOptions::create()
	   	->saveUniqueIdTo('user_unique_id') // this is the unique key column 
	      	->uniqueIdShouldBeNoLongerThan(8);
	}
}

the uniqueid is only available on model creating.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-05-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固