*/ public array $translatable = [ 'title', 'location', 'highlights', 'investment_case', 'location_info', 'contact', 'investor_trust', 'furniture_benefit', ]; protected function casts(): array { return [ 'launch_date' => 'date', 'price_from_aed' => 'integer', 'highlights' => 'array', 'quick_facts' => 'array', 'investment_case' => 'array', 'gallery' => 'array', 'location_info' => 'array', 'contact' => 'array', 'is_published' => 'boolean', 'order' => 'integer', ]; } public function scopePublished(Builder $query): Builder { return $query->where('is_published', true); } public function scopeOrdered(Builder $query): Builder { return $query->orderBy('order')->orderByDesc('launch_date'); } public function getFormattedPrice(string $prefix = 'ab'): string { if (! $this->price_from_aed) { return ''; } return PriceHelper::formatAed($this->price_from_aed, $prefix); } /** * Returns an array compatible with the existing Blade views * (immobilien.blade.php and immobilien-show.blade.php). * * @return array */ public function toFrontendArray(): array { return [ 'slug' => $this->slug, 'title' => $this->title, 'location' => $this->location, 'status' => $this->status, 'launch_date' => $this->launch_date?->format('d.m.Y'), 'price_from' => $this->getFormattedPrice(), 'image' => $this->image, 'highlights' => $this->highlights ?? [], 'quick_facts' => $this->quick_facts ?? [], 'investment_case' => $this->investment_case ?? [], 'gallery' => $this->gallery ?? [], 'location_info' => $this->location_info ?? [], 'contact' => $this->contact ?? [], 'investor_trust' => $this->investor_trust ?? [], 'furniture_benefit' => $this->furniture_benefit ?? [], ]; } }