承接 vanthao03596/laravel-ulid 相关项目开发

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

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

vanthao03596/laravel-ulid

Composer 安装命令:

composer require vanthao03596/laravel-ulid

包简介

Laravel package for ULID (Universally Unique Lexicographically Sortable Identifier)

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Installation

You can install the package via composer:

composer require vanthao03596/laravel-ulid

Usage

Generate uld from Str support class

// Default ulid generator with the current timestamp & lowercase string
Str::ulid(); // 01FDRXQ57VR4K4RASPT9NPAQC0
// Default ulid generator with the current timestamp & uppercase string
Str::ulid(false); // 01fdrxpmg9njp20z3km461fgax
// Default ulid generator with the given datetime & uppercase string
Str::ulid(false, Carbon::now()->subHour()) // 01FDRTD2K8Z664S24X606N14KD

Simply declare a ulid column type in your migration files.

Schema::create('foos', function (Blueprint $table) {
    $table->ulid('id')->primary(); // adds primary ulid column 
    $table->foreignUlid('user_id')->constrained()->cascadeOnDelete(); // adds ulid foreignkey
    $table->ulidMorphs('taggable'); // adds ulid morphs
    $table->nullableUlidMorphs('likeable'); // adds nullable ulid morphs
});

Auto generate ulid column in your model

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Vanthao03596\LaravelUlid\GeneratesUlid;

class User extends Model
{
    use GeneratesUlid;
}

Default column is ulid. If you wish to use a custom column name, for example if you want your primary custom_column column to be a ULID, you can define a ulidColumn method in your model.

class User extends Model
{
    public function ulidColumn(): string
    {
        return 'custom_column';
    }
}

You can have multiple ULID columns in each table by specifying an array in the ulidColumns method.

class User extends Model
{
    public function ulidColumns(): array
    {
        return ['ulid', 'custom_column'];
    }
}

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-08-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固