ActivityUser.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. namespace App\Models;
  3. use App\Constants\Util;
  4. /**
  5. * @property string $activity_id
  6. * @property string $finish_time
  7. * @property string member_id
  8. * @property string title
  9. * @property string status
  10. * @property string sub_title
  11. * @property string detail_image
  12. * @property string start_time
  13. * @property string end_time
  14. * @property string part_in_time
  15. * @property $effective_betting_amount
  16. * @property $gift_amount
  17. * @property $betting_amount
  18. *
  19. */
  20. class ActivityUser extends BaseModel
  21. {
  22. protected $table = 'activity_user';
  23. protected $fillable = ['activity_id',
  24. 'finish_time', 'member_id', 'title', 'status', 'sub_title', 'detail_image',
  25. 'start_time', 'end_time', 'part_in_time',
  26. 'effective_betting_amount', 'gift_amount',
  27. ];
  28. const STATUS_APPLY = 0;
  29. const STATUS_IN_PROGRESS = 1;
  30. const STATUS_COMPLETE = 2;
  31. public function member()
  32. {
  33. return $this->belongsTo(User::class, 'member_id', 'member_id')
  34. ->select(['id', 'member_id', 'username', 'first_name', 'status']);
  35. }
  36. protected function getDetailImageAttribute($value)
  37. {
  38. return Util::ensureUrl($value);
  39. }
  40. protected function getPartInTimeAttribute($value): string
  41. {
  42. return date('Y-m-d H:i:s', $value);
  43. }
  44. protected function getFinishTimeAttribute($value): string
  45. {
  46. if ($value > 1) {
  47. return date('Y-m-d H:i:s', $value);
  48. }
  49. return "";
  50. }
  51. protected function getStartTimeAttribute($value): string
  52. {
  53. return date('Y-m-d', $value);
  54. }
  55. protected function getEndTimeAttribute($value): string
  56. {
  57. return date('Y-m-d', $value);
  58. }
  59. }