'array', 'starts_at' => 'datetime', 'ends_at' => 'datetime', 'is_active' => 'boolean', 'show_topbar' => 'boolean', 'show_on_homepage' => 'boolean', 'discount_percent' => 'integer', 'sort_order' => 'integer', ]; public function scopeActive(Builder $query): Builder { return $query->where('is_active', true) ->where(function ($q) { $q->whereNull('starts_at') ->orWhere('starts_at', '<=', now()); }) ->where(function ($q) { $q->whereNull('ends_at') ->orWhere('ends_at', '>=', now()); }); } public function scopeForTopbar(Builder $query): Builder { return $query->active()->where('show_topbar', true); } public static function getActiveTopbar(): ?self { return static::forTopbar()->latest()->first(); } public function scopeForHomepage(Builder $query): Builder { return $query->active()->where('show_on_homepage', true)->orderBy('sort_order'); } public static function getHomepagePromos() { return static::forHomepage()->get(); } public static function getProductTypes(): array { return [ self::TYPE_DOMAINS => 'Domains', self::TYPE_HOSTING => 'Hosting', self::TYPE_VPS => 'VPS', self::TYPE_DEDICATED => 'Dedicated Servers', self::TYPE_EMAIL => 'Email', self::TYPE_GENERAL => 'General', ]; } public function getFeaturedImageUrlAttribute(): ?string { if (!$this->featured_image) { return null; } if (str_starts_with($this->featured_image, 'http')) { return $this->featured_image; } return asset('storage/' . $this->featured_image); } }