ActivityReward.php 996 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace App\Models;
  3. use App\Constants\Util;
  4. use Illuminate\Database\Eloquent\Relations\HasMany;
  5. /**
  6. * @property string $title
  7. * @property string sub_title
  8. * @property string detail_image
  9. * @property string start_time
  10. * @property string end_time
  11. * @property string status
  12. *
  13. */
  14. class ActivityReward extends BaseModel
  15. {
  16. const STATUS_UP = 1;
  17. const STATUS_DOWN = 0;
  18. protected $table = 'activity_rewards';
  19. protected $fillable = ['title', 'sub_title', 'detail_image', 'start_time', 'end_time', 'status'];
  20. public function activityUser(): HasMany
  21. {
  22. return $this->hasMany(ActivityUser::class, 'activity_id', 'id');
  23. }
  24. protected function getDetailImageAttribute($value)
  25. {
  26. return Util::ensureUrl($value);
  27. }
  28. protected function getStartTimeAttribute($value): string
  29. {
  30. return date('Y-m-d', $value);
  31. }
  32. protected function getEndTimeAttribute($value): string
  33. {
  34. return date('Y-m-d', $value);
  35. }
  36. }