ActivityMatchModel.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 ActivityMatchModel extends BaseModel
  19. {
  20. // 设置数据表
  21. protected $table = 'activitys_matchs';
  22. protected $appends = ['time_text'];
  23. // 时间
  24. public function getTimeTextAttribute()
  25. {
  26. return $this->create_time? datetime($this->create_time,'Y-m-d H:i:s') : '';
  27. }
  28. /**
  29. * 签到用户
  30. */
  31. public function member()
  32. {
  33. return $this->hasOne(MemberModel::class, 'id','user_id')
  34. ->where(['mark'=>1])
  35. ->select(['id', 'nickname','avatar', 'realname','mobile','gender', 'status']);
  36. }
  37. /**
  38. * 活动
  39. */
  40. public function activity()
  41. {
  42. return $this->hasOne(ActivityModel::class, 'id','activity_id')
  43. ->where(['mark'=>1])
  44. ->select(['id', 'title','thumb', 'type', 'status']);
  45. }
  46. }