FundCurrencyModel.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. namespace App\Module\Fund\Models;
  3. use App\Module\Fund\Casts\FundCurrencyDisplayAttributesCast;
  4. use App\Module\Fund\Enums\FUND_CURRENCY_TYPE;
  5. use UCore\ModelCore;
  6. /**
  7. * 币种配置表
  8. *
  9. * 用于存储系统支持的各种币种信息,如美元、人民币、比特币等。
  10. * 一个币种可以对应多个账户种类(FundConfigModel)。
  11. *
  12. * field start
  13. * @property int $id 自增
  14. * @property string $identification 资金标识
  15. * @property \App\Module\Fund\Enums\FUND_CURRENCY_TYPE $type 币种类型,关联FUND_CURRENCY_TYPE枚举
  16. * @property string $icon 资金标识
  17. * @property string $name 资金名字
  18. * @property \App\Module\Fund\Casts\FundCurrencyDisplayAttributesCast $display_attributes 显示属性,如图标、颜色等
  19. * @property int $create_time
  20. * @property int $update_time 更新时间
  21. * field end
  22. */
  23. class FundCurrencyModel extends ModelCore
  24. {
  25. protected $table = 'fund_currency';
  26. // attrlist start
  27. protected $fillable = [
  28. 'id',
  29. 'identification',
  30. 'type',
  31. 'icon',
  32. 'name',
  33. 'display_attributes',
  34. 'create_time',
  35. 'update_time',
  36. ];
  37. // attrlist end
  38. /**
  39. * 应该被转换为原生类型的属性
  40. *
  41. * @var array
  42. */
  43. protected $casts = [
  44. 'type' => FUND_CURRENCY_TYPE::class,
  45. 'display_attributes' => FundCurrencyDisplayAttributesCast::class,
  46. ];
  47. public $timestamps = false;
  48. /**
  49. * 获取该币种的所有账户种类
  50. *
  51. * 一个币种可以有多个账户种类,这是一对多关系中的"一"一方
  52. *
  53. * @return \Illuminate\Database\Eloquent\Relations\HasMany
  54. */
  55. public function fundConfigs()
  56. {
  57. return $this->hasMany(FundConfigModel::class, 'currency_id');
  58. }
  59. }