| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
- namespace App\Module\Fund\Models;
- use App\Module\Fund\Casts\FundDisplayAttributesCast;
- use App\Module\Fund\Enums\FUND_TYPE;
- use UCore\ModelCore;
- /**
- * 账户种类配置表
- *
- * 用于存储系统支持的各种账户种类,如可用账户、冻结账户等。
- * 同一个币种(FundCurrencyModel)可以有多个不同的账户种类。
- *
- * field start
- * @property int $id 自增
- * @property string $name 资金名字
- * @property int $currency_id 关联的币种ID,外键关联kku_fund_currency表
- * @property \App\Module\Fund\Enums\FUND_TYPE $type 账户种类类型,关联FUND_TYPE枚举
- * @property \App\Module\Fund\Casts\FundDisplayAttributesCast $display_attributes 显示属性,如图标、颜色等
- * @property int $create_time
- * @property int $update_time 更新时间
- * field end
- */
- class FundConfigModel extends ModelCore
- {
- protected $table = 'fund_config';
- // attrlist start
- protected $fillable = [
- 'id',
- 'name',
- 'currency_id',
- 'type',
- 'display_attributes',
- 'create_time',
- 'update_time',
- ];
- // attrlist end
- public $timestamps = false;
- /**
- * 应该被转换为原生类型的属性
- *
- * @var array
- */
- protected $casts = [
- 'type' => FUND_TYPE::class,
- 'display_attributes' => FundDisplayAttributesCast::class,
- ];
- /**
- * 获取关联的币种
- *
- * 一个账户种类属于一个币种,这是一对多关系中的"多"一方
- *
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
- */
- public function currency()
- {
- return $this->belongsTo(FundCurrencyModel::class, 'currency_id');
- }
- /**
- * 获取显示属性
- *
- * @return FundDisplayAttributesCast|null
- */
- public function getDisplayAttributes(): ?FundDisplayAttributesCast
- {
- return $this->display_attributes;
- }
- /**
- * 设置显示属性
- *
- * @param array|FundDisplayAttributesCast $attributes
- * @return $this
- */
- public function setDisplayAttributes($attributes)
- {
- $this->display_attributes = $attributes;
- return $this;
- }
- }
|