PromotionActivity.php 1.3 KB

1234567891011121314151617181920
  1. <?php
  2. namespace App\Models;
  3. use App\Support\PromotionRules;
  4. /** Independent campaigns. They never appear in activity_rewards or its legacy catalog. */
  5. class PromotionActivity extends BaseModel
  6. {
  7. protected $table = 'promotion_activities';
  8. protected $guarded = ['id', 'rewarded_count', 'budget_used'];
  9. protected $fillable = ['title', 'translations', 'type', 'status', 'start_time', 'end_time', 'lang', 'sort', 'params', 'content', 'image',
  10. 'publish_platforms', 'register_time_limited', 'register_start_time', 'register_end_time', 'register_platforms',
  11. 'deposit_limited', 'deposit_min', 'deposit_max', 'show_ineligible', 'reward_quota', 'budget'];
  12. protected $casts = ['translations' => 'array', 'publish_platforms' => 'array', 'register_platforms' => 'array', 'register_time_limited' => 'boolean',
  13. 'deposit_limited' => 'boolean', 'show_ineligible' => 'boolean', 'quota_enabled' => 'boolean', 'budget' => 'decimal:2', 'budget_used' => 'decimal:2',
  14. 'reward_quota' => 'integer', 'rewarded_count' => 'integer', 'deposit_min' => 'decimal:2', 'deposit_max' => 'decimal:2'];
  15. protected $appends = ['type_name'];
  16. protected function getTypeNameAttribute(): ?string { return PromotionRules::types()[(int)($this->attributes['type'] ?? 0)] ?? null; }
  17. }