AccountLogModel.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2017~2021 LARAVEL研发中心
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://www.laravel.cn
  8. // +----------------------------------------------------------------------
  9. // | Author: laravel开发员 <laravel.qq.com>
  10. // +----------------------------------------------------------------------
  11. namespace App\Models;
  12. /**
  13. * 账户明细-模型
  14. * @author laravel开发员
  15. * @since 2020/11/11
  16. * @package App\Models
  17. */
  18. class AccountLogModel extends BaseModel
  19. {
  20. // 设置数据表
  21. protected $table = 'account_logs';
  22. protected $appends = ['time_text','type_name'];
  23. // 时间
  24. public function getTimeTextAttribute()
  25. {
  26. return $this->create_time? datetime($this->create_time,'Y-m-d H:i:s') : '';
  27. }
  28. // 类型
  29. public function getTypeNameAttribute()
  30. {
  31. $types = [1=>'订单付款-商品',2=>'充值-余额',3=>'订单退款-商品',4=>'余额提现',5=>'余额转出-驳回',6=>'平台转入-余额',7=>'收益-企业',8=>'收益-佣金',9=>'收益-其他',10=>'转账-余额'];
  32. return $this->remark? $this->remark : (isset($types[$this->type])?$types[$this->type]:'账户交易');
  33. }
  34. /**
  35. * 用户
  36. * @return \Illuminate\Database\Eloquent\Relations\HasOne
  37. */
  38. public function member()
  39. {
  40. return $this->hasOne(MemberModel::class, 'id','user_id')
  41. ->select(['id','mobile','nickname','status']);
  42. }
  43. }