qumuinc/ulidtypes
最新稳定版本:v0.0.5
Composer 安装命令:
composer require qumuinc/ulidtypes
包简介
UlidType plugin for CakePHP
README 文档
README
Setup
Install
$ composer require qumuinc/ulidtypes
Bootstrap
- add plugin load command in
config/bootstrap.php
... Plugin::load('qumuinc/UlidTypes', ['bootstrap' => true]); ...
Model
- add
_initializeSchema()method toModel\Tableclass to make idulidtype
... use Cake\Database\Schema\TableSchemaInterface; ... class XXXXXXXXTable extends Table { protected function _initializeSchema(TableSchemaInterface $table): TableSchemaInterface { parent::_initializeSchema($table); $table->setColumnType('id', 'ulid'); // set ulid type for id return $table; } } ...
Or, you can use a trait.
... use PrefixUlidType\PrefixUlidTypeTrait; ... class XXXXXXXXTable extends Table { use PrefixUlidTypeTrait; } ...
If you want to use _initializeSchema function in your model, you need to call the _traitInitSchema function.
... use Cake\Database\Schema\TableSchemaInterface; use PrefixUlidType\PrefixUlidTypeTrait; ... class XXXXXXXXTable extends Table { use PrefixUlidTypeTrait; protected function _initializeSchema(TableSchemaInterface $table): TableSchemaInterface { parent::_traitInitSchema($table); $table->setColumnType('code', 'char'); // set any type for property return $table; } } ...
统计信息
- 总下载量: 1.44k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-10-04