attributes['click_type'] ?? 'none'); return in_array($value, ['none', 'external', 'internal'], true) ? $value : 'none'; } protected function getLinkAttribute($value): ?string { return in_array($this->click_type, ['external', 'internal'], true) ? ($value ?? ($this->attributes['link'] ?? null)) : null; } protected function getCanJumpAttribute(): bool { return in_array($this->click_type, ['external', 'internal'], true) && !empty($this->link) && $this->click_position !== null; } protected function getClickPositionAttribute($value): ?string { $value = $value ?? ($this->attributes['click_position'] ?? null); return $this->click_type !== 'none' && in_array($value, ['cover', 'detail'], true) ? $value : null; } 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 getTypeNameAttribute(): ?string { return ActivityCatalog::activityTypes()[(int) ($this->attributes['type'] ?? 0)] ?? null; } protected function getGameCategoryNameAttribute(): ?string { return ActivityCatalog::gameTypes()[$this->attributes['game_category'] ?? ''] ?? null; } 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); } }