| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php
- namespace App\Models;
- use App\Constants\Util;
- use Illuminate\Database\Eloquent\Relations\HasMany;
- /**
- * @property string $title
- * @property string sub_title
- * @property string detail_image
- * @property string start_time
- * @property string end_time
- * @property string status
- *
- */
- class ActivityReward extends BaseModel
- {
- const STATUS_UP = 1;
- const STATUS_DOWN = 0;
- protected $table = 'activity_rewards';
- protected $fillable = ['title', 'sub_title', 'detail_image', 'start_time', 'end_time', 'status','type','lang','content', 'params','pc_image','detail_banner', 'pc_banner',
- 'publish_platforms', 'budget', 'reward_quota', 'sort', 'register_time_limited', 'register_start_time', 'register_end_time',
- 'register_platforms', 'deposit_limited', 'deposit_min', 'deposit_max', 'show_ineligible'];
- protected $casts = [
- 'publish_platforms' => 'array', 'register_platforms' => 'array',
- 'register_time_limited' => 'boolean', 'deposit_limited' => 'boolean',
- 'show_ineligible' => 'boolean', 'reward_quota' => 'integer', 'rewarded_count' => 'integer',
- 'quota_enabled' => 'boolean', 'budget' => 'decimal:2', 'budget_used' => 'decimal:2',
- 'deposit_min' => 'decimal:2', 'deposit_max' => 'decimal:2', 'sort' => 'integer',
- ];
- public function activityUser(): HasMany
- {
- return $this->hasMany(ActivityUser::class, 'activity_id', 'id');
- }
- protected function getDetailImageAttribute($value)
- {
- return Util::ensureUrl($value);
- }
- protected function setDetailImageAttribute($value)
- {
- $this->attributes['detail_image'] = Util::replacePartInUrl($value);
- }
- protected function getPcImageAttribute($value)
- {
- return Util::ensureUrl($value);
- }
- protected function setPcImageAttribute($value)
- {
- $this->attributes['pc_image'] = Util::replacePartInUrl($value);
- }
- protected function getStartTimeAttribute($value): string
- {
- return date('Y-m-d', $value);
- }
- protected function getEndTimeAttribute($value): string
- {
- return date('Y-m-d', $value);
- }
- }
|