floor9design/laravel-casts-uuid

一个将 ramsey/uuid 转换为 Laravel 模型的类

1.1.1 2023-02-16 01:09 UTC

This package is auto-updated.

Last update: 2024-09-16 04:20:56 UTC


README

Latest Version Software License

Build Status Build Status

Github Downloads Packagist Downloads

简介

Laravel 框架支持在模型中转换类型。此类为 Laravel 模型添加了对 ramsey/uuid UUID 类的支持。

安装

将以下内容添加到 composer.json

    "require": {
        "floor9design/laravel-casts-uuid": "^1.0",
    }

设置

无需进行特定的配置设置步骤。该类应在 PSR-4 兼容的系统下自动加载。如果您单独使用该类,只需在使用模型时包含它即可

use Floor9design\LaravelCasts\Uuid as UuidCasts;

protected $casts = [
    'uuid' => UuidCasts::class
];

注意别名 - 通常将转换类别名为别名很有用,因为它可能与其他 Uuid 类(如基本 Uuid 类)冲突

use Ramsey\Uuid\Uuid;

// somewhere in the code:
$uuid = Uuid::uuid4();

测试

Build Status Build Status

可以按以下方式运行测试

  • ./vendor/phpunit/phpunit/phpunit

可以使用 phpstan 进行静态分析和代码审查

  • ./vendor/bin/phpstan

以下测试还可以创建代码覆盖率(通常保持在 100%)

  • ./vendor/phpunit/phpunit/phpunit --coverage-html docs/tests/

鸣谢

变更日志

在此处生成变更日志

许可证

此软件为专有软件。