mirror of
https://github.com/pacnpal/thrillwiki_laravel.git
synced 2025-12-21 21:31:10 -05:00
Add photo management features, update database configuration, and enhance park model seeding
This commit is contained in:
120
memory-bank/prompts/ParkModelEnhancements.md
Normal file
120
memory-bank/prompts/ParkModelEnhancements.md
Normal file
@@ -0,0 +1,120 @@
|
||||
# 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`
|
||||
97
memory-bank/prompts/PhotoManagementImplementation.md
Normal file
97
memory-bank/prompts/PhotoManagementImplementation.md
Normal file
@@ -0,0 +1,97 @@
|
||||
# Photo Management Implementation
|
||||
|
||||
## Overview
|
||||
This prompt outlines the next steps for implementing photo management capabilities for the ThrillWiki Laravel application. Building on the recently completed Park model enhancements, we now need to create the UI and controllers for managing photos.
|
||||
|
||||
## Current Status
|
||||
The Photo model and relationships have been implemented, including:
|
||||
- A polymorphic Photo model that can be associated with any model
|
||||
- Methods for adding, featuring, and reordering photos
|
||||
- Database migrations for the photos table
|
||||
- Unit tests for all photo-related functionality
|
||||
|
||||
## Required Features
|
||||
|
||||
### 1. Photo Upload Controller
|
||||
Implement a controller for handling photo uploads:
|
||||
|
||||
```php
|
||||
// Example controller method structure
|
||||
public function store(Request $request, Park $park)
|
||||
{
|
||||
$request->validate([
|
||||
'photo' => 'required|image|max:10240', // 10MB max
|
||||
'title' => 'nullable|string|max:255',
|
||||
'description' => 'nullable|string',
|
||||
'is_featured' => 'nullable|boolean',
|
||||
]);
|
||||
|
||||
// Handle file upload
|
||||
// Create photo record
|
||||
// Return response
|
||||
}
|
||||
```
|
||||
|
||||
Tasks:
|
||||
- Create a PhotoController with CRUD operations
|
||||
- Implement file upload handling with proper validation
|
||||
- Store uploaded files in the storage/app/public/photos directory
|
||||
- Generate thumbnails for uploaded images
|
||||
- Handle setting featured photos
|
||||
|
||||
### 2. Photo Management UI
|
||||
Create Livewire components for managing photos:
|
||||
|
||||
Tasks:
|
||||
- Create a PhotoUploadComponent for uploading new photos
|
||||
- Implement a PhotoGalleryComponent for displaying photos
|
||||
- Add a PhotoManagerComponent for reordering and deleting photos
|
||||
- Create a FeaturedPhotoSelectorComponent for choosing the featured photo
|
||||
|
||||
### 3. Park Detail Page Photo Display
|
||||
Update the park detail page to display photos:
|
||||
|
||||
Tasks:
|
||||
- Add a photo gallery section to the park detail page
|
||||
- Display the featured photo prominently
|
||||
- Implement a carousel or grid for additional photos
|
||||
- Add photo metadata display (title, description, credit)
|
||||
|
||||
### 4. Photo API Endpoints
|
||||
Create API endpoints for photo management:
|
||||
|
||||
Tasks:
|
||||
- Implement RESTful endpoints for photo CRUD operations
|
||||
- Add endpoints for reordering photos
|
||||
- Create an endpoint for setting the featured photo
|
||||
- Implement proper authorization for photo management
|
||||
|
||||
### 5. Photo Storage Configuration
|
||||
Configure the application for proper photo storage:
|
||||
|
||||
Tasks:
|
||||
- Set up the public disk for storing photos
|
||||
- Configure image processing for thumbnails and optimized versions
|
||||
- Implement proper file naming and organization
|
||||
- Add configuration for maximum file sizes and allowed types
|
||||
|
||||
## Implementation Approach
|
||||
1. Start with the PhotoController and file upload handling
|
||||
2. Implement the Livewire components for the UI
|
||||
3. Update the park detail page to display photos
|
||||
4. Add the API endpoints for programmatic access
|
||||
5. Configure the storage and file processing
|
||||
|
||||
## Expected Outcome
|
||||
After implementing these features, the application will have:
|
||||
- A complete photo management system
|
||||
- The ability to upload, organize, and display photos for parks
|
||||
- A user-friendly interface for managing photos
|
||||
- Proper storage and optimization of uploaded images
|
||||
|
||||
## References
|
||||
- Photo model: `app/Models/Photo.php`
|
||||
- Park model: `app/Models/Park.php`
|
||||
- Park detail page: (to be implemented)
|
||||
- Laravel file storage documentation: https://laravel.com/docs/10.x/filesystem
|
||||
- Livewire documentation: https://laravel-livewire.com/docs
|
||||
Reference in New Issue
Block a user