12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- namespace app\admin\model;
- use think\Model;
- /**
- * PayApply
- */
- class PayApply extends Model
- {
- // 表名
- protected $name = 'pay_apply';
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = true;
- protected static function onBeforeInsert($model)
- {
- $pk = $model->getPk();
- $model->$pk = \app\common\library\SnowFlake::generateParticle();
- }
- public function getIdAttr($value): string
- {
- return (string)$value;
- }
- public function getPayAmountAttr($value): float
- {
- return (float)$value;
- }
- public function getImagesAttr($value): array
- {
- if ($value === '' || $value === null) return [];
- if (!is_array($value)) {
- return explode(',', $value);
- }
- return $value;
- }
- public function setImagesAttr($value): string
- {
- return is_array($value) ? implode(',', $value) : $value;
- }
- public function reqOrder()
- {
- return $this->belongsTo(\app\admin\model\ReqOrder::class, 'req_id', 'id');
- }
- }
|