attributes->get('tenant_id'); $showSensitive = $this->tenant_id === $tenantId; $settings = is_array($this->settings) ? $this->settings : []; $eventPackage = null; if ($this->relationLoaded('eventPackages')) { $related = $this->getRelation('eventPackages'); if (! $related instanceof MissingValue) { $eventPackage = $related->first(); } } elseif ($this->relationLoaded('eventPackage')) { $related = $this->getRelation('eventPackage'); if (! $related instanceof MissingValue) { $eventPackage = $related; } } return [ 'id' => $this->id, 'name' => $this->name, 'slug' => $this->slug, 'description' => $this->description, 'event_date' => $this->date ? $this->date->toISOString() : null, 'location' => $this->location, 'max_participants' => $this->max_participants, 'current_participants' => $showSensitive ? ($this->photos_count ?? null) : null, 'public_url' => $settings['public_url'] ?? null, 'custom_domain' => $showSensitive ? ($settings['custom_domain'] ?? null) : null, 'theme_color' => $settings['theme_color'] ?? null, 'status' => $this->status ?? 'draft', 'is_active' => (bool) ($this->is_active ?? false), 'features' => $settings['features'] ?? [], 'engagement_mode' => $settings['engagement_mode'] ?? 'tasks', 'settings' => $settings, 'event_type_id' => $this->event_type_id, 'created_at' => $this->created_at?->toISOString(), 'updated_at' => $this->updated_at?->toISOString(), 'photo_count' => $this->photos_count ?? 0, 'like_count' => $this->whenLoaded('photos', fn () => $this->photos->sum('likes_count'), 0), 'is_public' => $this->status === 'published', 'public_share_url' => null, 'qr_code_url' => null, 'package' => $eventPackage ? [ 'id' => $eventPackage->package_id, 'name' => $eventPackage->package?->getNameForLocale(app()->getLocale()) ?? $eventPackage->package?->name, 'price' => $eventPackage->purchased_price, 'purchased_at' => $eventPackage->purchased_at?->toIso8601String(), 'expires_at' => $eventPackage->gallery_expires_at?->toIso8601String(), ] : null, ]; } }