MemberModel.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. * Class MemberModel
  17. * @package App\Models
  18. */
  19. class MemberModel extends BaseModel
  20. {
  21. // 设置数据表
  22. protected $table = 'member';
  23. /**
  24. * 商家
  25. * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
  26. */
  27. public function merchant()
  28. {
  29. return $this->belongsTo(MerchantModel::class, 'id','user_id')
  30. ->where(['mark'=>1])
  31. ->select(['id','user_id','balance','name','category','type','audit_remark','status']);
  32. }
  33. /**
  34. * 承兑商
  35. * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
  36. */
  37. public function acceptor()
  38. {
  39. return $this->belongsTo(AcceptorModel::class, 'id','user_id')
  40. ->where(['mark'=>1])
  41. ->select(['id','user_id','realname','mobile','usdt','quota','audit_remark','status']);
  42. }
  43. /**
  44. * 获取会员信息
  45. * @param int $id 会员ID
  46. * @return array|string
  47. * @author laravel开发员
  48. * @since 2020/11/11
  49. */
  50. public function getInfo($id)
  51. {
  52. $info = parent::getInfo($id); // TODO: Change the autogenerated stub
  53. if ($info) {
  54. // 头像
  55. if ($info['avatar']) {
  56. $info['avatar'] = get_image_url($info['avatar']);
  57. }
  58. // 出生日期
  59. if ($info['birthday']) {
  60. $info['birthday'] = datetime($info['birthday']);
  61. }
  62. // 城市
  63. if ($info['province_id'] && $info['city_id'] && $info['district_id']) {
  64. $city = [];
  65. $city[] = $info['province_id'];
  66. $city[] = $info['city_id'];
  67. $city[] = $info['district_id'];
  68. $info['city'] = $city;
  69. }
  70. }
  71. return $info;
  72. }
  73. }