# Park Model Enhancements

## Overview
This prompt outlines the next features to implement in the Laravel Park model to maintain feature parity with the Django implementation.

## Current Status
The Laravel Park model has been implemented with basic properties, relationships, and some utility methods. The parks list page has been implemented to match the Django source. However, several key features from the Django Park model are still missing.

## Required Enhancements

### 1. Photos Relationship
Implement a relationship to photos similar to the Django GenericRelation:

```php
// In the Django model:
photos = GenericRelation(Photo, related_query_name="park")
```

Tasks:
- Create a Photo model with polymorphic relationships
- Add a morphMany relationship to the Park model
- Implement methods for adding/removing photos
- Ensure the first photo is used for park cards

### 2. Get By Slug Method
Implement the `getBySlug` static method to find parks by current or historical slugs:

```php
// In the Django model:
@classmethod
def get_by_slug(cls, slug: str) -> Tuple['Park', bool]:
    """Get park by current or historical slug"""
    // Implementation details...
```

Tasks:
- Create a static method in the Park model
- Implement logic to check current slugs first
- Add fallback to check historical slugs
- Return both the park and a boolean indicating if a historical slug was used

### 3. Absolute URL Method
Implement the `getAbsoluteUrl` method:

```php
// In the Django model:
def get_absolute_url(self) -> str:
    return reverse("parks:park_detail", kwargs={"slug": self.slug})
```

Tasks:
- Add a method to generate the URL for the park detail page
- Use Laravel's route() helper with the park's slug

### 4. Formatted Location Property
Implement the `formatted_location` property:

```php
// In the Django model:
@property
def formatted_location(self) -> str:
    if self.location.exists():
        location = self.location.first()
        if location:
            return location.get_formatted_address()
    return ""
```

Tasks:
- Add a `getFormattedLocationAttribute` method to the Park model
- Use the existing Location relationship
- Return a formatted address string

### 5. Coordinates Property
Implement the `coordinates` property:

```php
// In the Django model:
@property
def coordinates(self) -> Optional[Tuple[float, float]]:
    """Returns coordinates as a tuple (latitude, longitude)"""
    if self.location.exists():
        location = self.location.first()
        if location:
            return location.coordinates
    return None
```

Tasks:
- Add a `getCoordinatesAttribute` method to the Park model
- Return an array with latitude and longitude

### 6. Media Management
Implement photo management capabilities:

Tasks:
- Create methods for adding photos to parks
- Implement photo ordering
- Add methods for setting a featured photo
- Ensure photos are displayed on park detail pages

## Implementation Approach
1. Start with the Photo model and polymorphic relationships
2. Implement the Park model enhancements one by one
3. Update the park detail page to display photos
4. Add methods for managing photos
5. Test all new functionality against the Django implementation

## Expected Outcome
After implementing these enhancements, the Laravel Park model will have feature parity with the Django implementation, including:
- Full photo management capabilities
- Robust slug handling with historical slug support
- Proper location display and coordinates access
- Complete URL generation for navigation

## References
- Django Park model: `//Volumes/macminissd/Projects/thrillwiki_django_no_react/parks/models.py`
- Laravel Park model: `app/Models/Park.php`
- HasSlugHistory trait: `app/Traits/HasSlugHistory.php`
- HasLocation trait: `app/Traits/HasLocation.php`