glorand / laravel-eloquent-model-uuid
为Eloquent模型的ID提供UUID支持的简单解决方案。
4.0.0
2022-02-10 07:57 UTC
Requires
- php: >=7.1.3
- illuminate/database: ~5.8.0|^6.0|^7.0|^8.0|^9.0
- illuminate/support: ~5.8.0|^6.0|^7.0|^8.0|^9.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.16@dev|^3.6
- orchestra/testbench: ~3.8.0|^4.0|^5.0|^7.0
- phpunit/phpunit: ^7.5|^8.0|^9.0
This package is auto-updated.
Last update: 2024-09-19 20:20:08 UTC
README
为Eloquent模型的ID提供UUID支持的简单解决方案。
安装
您可以通过composer安装此包
composer require glorand/laravel-eloquent-model-uuid
用法
让我们从数据库方面开始。
$table->uuid('id'); $table->primary('id'); //OR $table->uuid('id')->primary();
使用此包提供的模型类
而不是扩展标准的Laravel模型类,扩展此包提供的模型类
<?php use Glorand\LaravelEloquentModelUuid\Database\Eloquent\Model; class Entity extends Model { // }
在模型类上使用Trait
<?php use Illuminate\Database\Eloquent\Model; use Glorand\LaravelEloquentModelUuid\Database\Concerns\Uuid; class Entity extends Model { use Uuid; /** * The "type" of the auto-incrementing ID. * * @var string */ protected $keyType = 'string'; /** * Indicates if the IDs are auto-incrementing. * * @var bool */ public $incrementing = false; // }
测试
composer test
变更日志
请参阅CHANGELOG以获取更多信息。
贡献
请参阅CONTRIBUTING以获取详细信息。
安全
如果您发现任何安全问题,请通过电子邮件gombos.lorand@gmail.com联系,而不是使用问题跟踪器。
许可证
MIT许可证(MIT)。请参阅许可证文件以获取更多信息。