ReqInvoiceApply.php 748 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace app\admin\model;
  3. use think\Model;
  4. /**
  5. * ReqInvoiceApply
  6. */
  7. class ReqInvoiceApply extends Model
  8. {
  9. // 表名
  10. protected $name = 'req_invoice_apply';
  11. // 自动写入时间戳字段
  12. protected $autoWriteTimestamp = true;
  13. protected static function onBeforeInsert($model)
  14. {
  15. $pk = $model->getPk();
  16. $model->$pk = \app\common\library\SnowFlake::generateParticle();
  17. }
  18. public function getIdAttr($value): string
  19. {
  20. return (string)$value;
  21. }
  22. public function getInvoiceAmountAttr($value): float
  23. {
  24. return (float)$value;
  25. }
  26. public function reqOrder()
  27. {
  28. return $this->belongsTo(\app\admin\model\ReqOrder::class, 'req_id', 'id');
  29. }
  30. }