brokeyourbike/uid-keys

为Eloquent模型的ID提供UUID和ULID支持的简单即插即用解决方案。

0.1.1 2023-05-14 21:15 UTC

This package is auto-updated.

Last update: 2024-09-20 14:35:22 UTC


README

Latest Stable Version Total Downloads Maintainability Test Coverage

为Eloquent模型的ID提供UUID和ULID支持的简单即插即用解决方案。

安装

composer require brokeyourbike/uid-keys

使用

use Illuminate\Database\Eloquent\Model;
use BrokeYourBike\UidKeys\Database\Eloquent\Ulid;

class ExampleModel extends Model
{
    use Ulid;

    /**
     * The "type" of the auto-incrementing ID.
     *
     * @var string
     */
    protected $keyType = 'string';

    /**
     * Indicates if the IDs are auto-incrementing.
     *
     * @var bool
     */
    public $incrementing = false;
}

灵感来源

代码主要借鉴自goldspecdigital/laravel-eloquent-uuid 包。

作者

许可

Mozilla公共许可证v2.0