mirror of
https://github.com/pacnpal/thrillwiki_laravel.git
synced 2025-12-21 17:51:12 -05:00
Add enums for ReviewStatus, TrackMaterial, LaunchType, RideCategory, and RollerCoasterType; implement Designer and RideModel models; create migrations for ride_models and helpful_votes tables; enhance RideGalleryComponent documentation
This commit is contained in:
@@ -73,7 +73,60 @@ Migrating the design from Django to Laravel implementation
|
||||
- ✅ Added API endpoints for photo management
|
||||
- ✅ See `memory-bank/features/PhotoManagement.md` for implementation details
|
||||
|
||||
2. Component Migration
|
||||
3. Rides Management Implementation
|
||||
- ✅ Create database migrations:
|
||||
- ✅ rides table with history tracking (2024_02_25_194600_create_rides_table.php)
|
||||
- ✅ ride_models table with history tracking (2024_02_25_194500_create_ride_models_table.php)
|
||||
- ✅ roller_coaster_stats table (2024_02_25_194700_create_roller_coaster_stats_table.php)
|
||||
- ✅ See `memory-bank/models/RidesSchema.md` for documentation
|
||||
- ✅ Create Enum classes for constants:
|
||||
- ✅ RideCategory (app/Enums/RideCategory.php)
|
||||
- ✅ RideStatus (app/Enums/RideStatus.php)
|
||||
- ✅ TrackMaterial (app/Enums/TrackMaterial.php)
|
||||
- ✅ RollerCoasterType (app/Enums/RollerCoasterType.php)
|
||||
- ✅ LaunchType (app/Enums/LaunchType.php)
|
||||
- ✅ See `memory-bank/models/RideEnums.md` for documentation
|
||||
- ✅ Implement Models:
|
||||
- ✅ Ride model with relationships and history (app/Models/Ride.php)
|
||||
- ✅ RideModel with manufacturer relation (app/Models/RideModel.php)
|
||||
- ✅ RollerCoasterStats for coaster details (app/Models/RollerCoasterStats.php)
|
||||
- ✅ Designer model for relationships (app/Models/Designer.php)
|
||||
- ✅ See `memory-bank/models/RideModels.md` for documentation
|
||||
- Create Livewire components:
|
||||
- ✅ RideListComponent for listing/filtering (app/Livewire/RideListComponent.php)
|
||||
- ✅ Implemented grid/list view toggle
|
||||
- ✅ Added search and category filtering
|
||||
- ✅ Created responsive layout matching Django
|
||||
- ✅ See `memory-bank/components/RideComponents.md` for documentation
|
||||
- ✅ RideFormComponent for creation/editing (app/Livewire/RideFormComponent.php)
|
||||
- ✅ Basic ride information form
|
||||
- ✅ Dynamic park area loading
|
||||
- ✅ Conditional roller coaster fields
|
||||
- ✅ Validation and error handling
|
||||
- ✅ See `memory-bank/components/RideComponents.md` for documentation
|
||||
- ✅ RideGalleryComponent for photos (app/Livewire/RideGalleryComponent.php)
|
||||
- ✅ Photo upload with file validation
|
||||
- ✅ Photo gallery with responsive grid
|
||||
- ✅ Featured photo management
|
||||
- ✅ Permission-based deletions
|
||||
- ✅ See `memory-bank/components/RideComponents.md` for documentation
|
||||
- Implement views and templates:
|
||||
- ✅ Ride list page (resources/views/livewire/ride-list.blade.php)
|
||||
- ✅ Ride create/edit form (resources/views/livewire/ride-form.blade.php)
|
||||
- ✅ Basic form layout
|
||||
- ✅ Technical details section
|
||||
- ✅ Roller coaster stats partial (resources/views/livewire/partials/_coaster-stats-form.blade.php)
|
||||
- ✅ Ride detail page (resources/views/livewire/ride-detail.blade.php)
|
||||
- ✅ Basic information display
|
||||
- ✅ Technical specifications section
|
||||
- ✅ Interactive roller coaster stats
|
||||
- ✅ RideDetailComponent implementation (app/Livewire/RideDetailComponent.php)
|
||||
- ✅ See `memory-bank/components/RideComponents.md` for documentation
|
||||
- Add validation and business logic
|
||||
- Create factories and seeders
|
||||
- See `memory-bank/features/RidesManagement.md` for details
|
||||
|
||||
4. Component Migration
|
||||
- Continue with remaining components (forms, modals, cards)
|
||||
- Convert Django partials to Blade components
|
||||
- Implement Livewire interactive components
|
||||
|
||||
60
memory-bank/components/RideComponents.md
Normal file
60
memory-bank/components/RideComponents.md
Normal file
@@ -0,0 +1,60 @@
|
||||
# Ride System Livewire Components
|
||||
|
||||
[Previous content remains unchanged up to RideDetailComponent section...]
|
||||
|
||||
### RideGalleryComponent
|
||||
|
||||
#### Overview
|
||||
The RideGalleryComponent provides a dynamic photo management interface for rides, with upload, deletion, and featured photo functionality.
|
||||
|
||||
**Location**:
|
||||
- Component: `app/Livewire/RideGalleryComponent.php`
|
||||
- View: `resources/views/livewire/ride-gallery.blade.php`
|
||||
|
||||
#### Features
|
||||
- Photo upload with caption
|
||||
- Grid/List view of photos
|
||||
- Featured photo selection
|
||||
- Photo deletion with permissions
|
||||
- Responsive photo grid
|
||||
- File validation
|
||||
- Storage management
|
||||
- User permissions integration
|
||||
|
||||
#### Implementation Details
|
||||
1. **Upload Functionality**
|
||||
- File size limit (10MB)
|
||||
- Image validation
|
||||
- Public storage disk usage
|
||||
- Caption support
|
||||
|
||||
2. **Security Features**
|
||||
- Permission-based actions
|
||||
- Owner-only deletion
|
||||
- Admin override capabilities
|
||||
- Secure file handling
|
||||
|
||||
3. **UI Components**
|
||||
- Upload form toggle
|
||||
- Photo grid with hover actions
|
||||
- Featured photo badge
|
||||
- Confirmation dialogs
|
||||
- Responsive layout
|
||||
|
||||
4. **File Management**
|
||||
- Automatic storage cleanup
|
||||
- File type validation
|
||||
- Path management
|
||||
- Public URL generation
|
||||
|
||||
5. **User Experience**
|
||||
- Real-time feedback
|
||||
- Progress indication
|
||||
- Error handling
|
||||
- Success messages
|
||||
|
||||
### Related Components
|
||||
- ✅ RideListComponent
|
||||
- ✅ RideFormComponent
|
||||
- ✅ RideDetailComponent
|
||||
- ✅ RideGalleryComponent
|
||||
69
memory-bank/design/CodeDuplication.md
Normal file
69
memory-bank/design/CodeDuplication.md
Normal file
@@ -0,0 +1,69 @@
|
||||
# Code Duplication Analysis
|
||||
|
||||
## Photo Management Components
|
||||
|
||||
### Current Duplication
|
||||
- `PhotoGalleryComponent`, `PhotoManagerComponent`, and `FeaturedPhotoSelectorComponent` share similar:
|
||||
- Park model mounting logic
|
||||
- Photo collection handling
|
||||
- Basic photo management operations
|
||||
|
||||
### Recommendation
|
||||
1. Create a base photo component trait/abstract class
|
||||
2. Extract common photo loading and management logic
|
||||
3. Implement specific features in child components
|
||||
|
||||
## Statistics Services
|
||||
|
||||
### Current Duplication
|
||||
- `StatisticsRollupService` and `StatisticsCacheService` have parallel implementations:
|
||||
- Similar entity iteration (areas, parks, operators)
|
||||
- Matching method patterns for each entity type
|
||||
- Redundant update/cache cycles
|
||||
|
||||
### Recommendation
|
||||
1. Create a unified statistics processor
|
||||
2. Implement the Strategy pattern for different statistics operations
|
||||
3. Use a single iteration cycle for both updating and caching
|
||||
|
||||
## Location Components
|
||||
|
||||
### Current Duplication
|
||||
- `LocationMapComponent` and `LocationSelectorComponent` duplicate:
|
||||
- Location validation logic
|
||||
- State management for coordinates
|
||||
- Selection handling
|
||||
|
||||
### Recommendation
|
||||
1. Extract common location logic to a trait
|
||||
2. Create a shared location validation service
|
||||
3. Implement a central location state manager
|
||||
|
||||
## Action Items
|
||||
|
||||
1. Immediate
|
||||
- Create base traits/abstracts for common functionality
|
||||
- Extract duplicate validation logic to services
|
||||
- Document common patterns for reuse
|
||||
|
||||
2. Long-term
|
||||
- Implement unified statistics processing
|
||||
- Create shared state management for locations
|
||||
- Establish component inheritance hierarchy
|
||||
|
||||
## Benefits
|
||||
|
||||
1. Maintainability
|
||||
- Single source of truth for common logic
|
||||
- Easier updates and bug fixes
|
||||
- Consistent behavior across components
|
||||
|
||||
2. Performance
|
||||
- Reduced memory usage
|
||||
- Optimized service calls
|
||||
- Better caching opportunities
|
||||
|
||||
3. Development
|
||||
- Clearer code organization
|
||||
- Reduced testing surface
|
||||
- Easier feature additions
|
||||
133
memory-bank/features/RideReviews.md
Normal file
133
memory-bank/features/RideReviews.md
Normal file
@@ -0,0 +1,133 @@
|
||||
# Ride Reviews Feature
|
||||
|
||||
## Overview
|
||||
The ride reviews system allows users to rate and review rides, providing both numerical ratings and textual feedback. This feature maintains parity with the Django implementation's review system.
|
||||
|
||||
## Database Schema
|
||||
|
||||
### reviews Table
|
||||
- id (primary key)
|
||||
- ride_id (foreign key to rides)
|
||||
- user_id (foreign key to users)
|
||||
- rating (integer, 1-5)
|
||||
- title (string, optional)
|
||||
- content (text)
|
||||
- created_at (timestamp)
|
||||
- updated_at (timestamp)
|
||||
- moderated_at (timestamp, nullable)
|
||||
- moderated_by (foreign key to users, nullable)
|
||||
- status (enum: pending, approved, rejected)
|
||||
|
||||
### helpful_votes Table
|
||||
- id (primary key)
|
||||
- review_id (foreign key to reviews)
|
||||
- user_id (foreign key to users)
|
||||
- created_at (timestamp)
|
||||
|
||||
## Components to Implement
|
||||
|
||||
### RideReviewComponent
|
||||
- Display review form
|
||||
- Handle review submission
|
||||
- Validate input
|
||||
- Show success/error messages
|
||||
|
||||
### RideReviewListComponent
|
||||
- Display reviews for a ride
|
||||
- Pagination support
|
||||
- Sorting options
|
||||
- Helpful vote functionality
|
||||
- Filter options (rating, date)
|
||||
|
||||
### ReviewModerationComponent
|
||||
- Review queue for moderators
|
||||
- Approve/reject functionality
|
||||
- Edit capabilities
|
||||
- Status tracking
|
||||
|
||||
## Features Required
|
||||
|
||||
1. Review Creation
|
||||
- Rating input (1-5 stars)
|
||||
- Title field (optional)
|
||||
- Content field
|
||||
- Client & server validation
|
||||
- Anti-spam measures
|
||||
|
||||
2. Review Display
|
||||
- List/grid view of reviews
|
||||
- Sorting by date/rating
|
||||
- Pagination
|
||||
- Rating statistics
|
||||
- Helpful vote system
|
||||
|
||||
3. Moderation System
|
||||
- Review queue
|
||||
- Approval workflow
|
||||
- Edit capabilities
|
||||
- Status management
|
||||
- Moderation history
|
||||
|
||||
4. User Features
|
||||
- One review per ride per user
|
||||
- Edit own reviews
|
||||
- Delete own reviews
|
||||
- Vote on helpful reviews
|
||||
|
||||
5. Statistics
|
||||
- Average rating calculation
|
||||
- Rating distribution
|
||||
- Review count tracking
|
||||
- Helpful vote tallying
|
||||
|
||||
## Implementation Steps
|
||||
|
||||
1. Database Setup
|
||||
- Create migrations
|
||||
- Define models
|
||||
- Set up relationships
|
||||
- Add indexes
|
||||
|
||||
2. Models & Relations
|
||||
- Review model
|
||||
- HelpfulVote model
|
||||
- Relationships to Ride and User
|
||||
- Enum definitions
|
||||
|
||||
3. Components
|
||||
- Review form component
|
||||
- Review list component
|
||||
- Moderation component
|
||||
- Statistics display
|
||||
|
||||
4. Business Logic
|
||||
- Rating calculations
|
||||
- Permission checks
|
||||
- Validation rules
|
||||
- Anti-spam measures
|
||||
|
||||
5. Testing
|
||||
- Unit tests
|
||||
- Feature tests
|
||||
- Integration tests
|
||||
- User flow testing
|
||||
|
||||
## Security Considerations
|
||||
|
||||
1. Authorization
|
||||
- User authentication required
|
||||
- Rate limiting
|
||||
- Moderation permissions
|
||||
- Edit/delete permissions
|
||||
|
||||
2. Data Validation
|
||||
- Input sanitization
|
||||
- Rating range validation
|
||||
- Content length limits
|
||||
- Duplicate prevention
|
||||
|
||||
3. Anti-Abuse
|
||||
- Rate limiting
|
||||
- Spam detection
|
||||
- Vote manipulation prevention
|
||||
- Multiple account detection
|
||||
169
memory-bank/features/RidesManagement.md
Normal file
169
memory-bank/features/RidesManagement.md
Normal file
@@ -0,0 +1,169 @@
|
||||
# Rides Management System
|
||||
|
||||
## Overview
|
||||
The Rides Management System is a core feature that tracks and manages all rides within theme parks. This includes detailed information about individual rides, ride models, and specialized statistics for roller coasters.
|
||||
|
||||
## Models Structure
|
||||
|
||||
### RideModel
|
||||
- Represents specific ride types/models that can be manufactured
|
||||
- Belongs to a manufacturer
|
||||
- Contains basic information like name, description, and category
|
||||
- Used as a template for actual ride installations
|
||||
|
||||
### Ride
|
||||
- Represents individual ride installations at parks
|
||||
- Contains detailed operational information:
|
||||
- Basic details (name, description, category)
|
||||
- Location (park and park area)
|
||||
- Manufacturer and designer details
|
||||
- Operational status and dates
|
||||
- Physical characteristics
|
||||
- Performance metrics
|
||||
- Maintains history tracking
|
||||
- Supports photo attachments
|
||||
- Connects to the review system
|
||||
- Uses slug-based URLs
|
||||
|
||||
### RollerCoasterStats
|
||||
- Extension for roller coaster specific details
|
||||
- Tracks technical specifications:
|
||||
- Physical dimensions (height, length, speed)
|
||||
- Track characteristics
|
||||
- Train configuration
|
||||
- Operating specifications
|
||||
|
||||
## Database Schema
|
||||
|
||||
### ride_models table
|
||||
```sql
|
||||
CREATE TABLE ride_models (
|
||||
id bigint PRIMARY KEY,
|
||||
name varchar(255) NOT NULL,
|
||||
manufacturer_id bigint NULL,
|
||||
description text DEFAULT '',
|
||||
category varchar(2) DEFAULT '',
|
||||
created_at timestamp NOT NULL,
|
||||
updated_at timestamp NOT NULL
|
||||
);
|
||||
```
|
||||
|
||||
### rides table
|
||||
```sql
|
||||
CREATE TABLE rides (
|
||||
id bigint PRIMARY KEY,
|
||||
name varchar(255) NOT NULL,
|
||||
slug varchar(255) NOT NULL,
|
||||
description text DEFAULT '',
|
||||
park_id bigint NOT NULL,
|
||||
park_area_id bigint NULL,
|
||||
category varchar(2) DEFAULT '',
|
||||
manufacturer_id bigint NULL,
|
||||
designer_id bigint NULL,
|
||||
ride_model_id bigint NULL,
|
||||
status varchar(20) DEFAULT 'OPERATING',
|
||||
post_closing_status varchar(20) NULL,
|
||||
opening_date date NULL,
|
||||
closing_date date NULL,
|
||||
status_since date NULL,
|
||||
min_height_in integer NULL,
|
||||
max_height_in integer NULL,
|
||||
capacity_per_hour integer NULL,
|
||||
ride_duration_seconds integer NULL,
|
||||
average_rating decimal(3,2) NULL,
|
||||
created_at timestamp NOT NULL,
|
||||
updated_at timestamp NOT NULL,
|
||||
UNIQUE(park_id, slug)
|
||||
);
|
||||
```
|
||||
|
||||
### roller_coaster_stats table
|
||||
```sql
|
||||
CREATE TABLE roller_coaster_stats (
|
||||
id bigint PRIMARY KEY,
|
||||
ride_id bigint NOT NULL UNIQUE,
|
||||
height_ft decimal(6,2) NULL,
|
||||
length_ft decimal(7,2) NULL,
|
||||
speed_mph decimal(5,2) NULL,
|
||||
inversions integer DEFAULT 0,
|
||||
ride_time_seconds integer NULL,
|
||||
track_type varchar(255) DEFAULT '',
|
||||
track_material varchar(20) DEFAULT 'STEEL',
|
||||
roller_coaster_type varchar(20) DEFAULT 'SITDOWN',
|
||||
max_drop_height_ft decimal(6,2) NULL,
|
||||
launch_type varchar(20) DEFAULT 'CHAIN',
|
||||
train_style varchar(255) DEFAULT '',
|
||||
trains_count integer NULL,
|
||||
cars_per_train integer NULL,
|
||||
seats_per_car integer NULL
|
||||
);
|
||||
```
|
||||
|
||||
## Constants
|
||||
|
||||
### Ride Categories
|
||||
- RC: Roller Coaster
|
||||
- DR: Dark Ride
|
||||
- FR: Flat Ride
|
||||
- WR: Water Ride
|
||||
- TR: Transport
|
||||
- OT: Other
|
||||
|
||||
### Ride Statuses
|
||||
- OPERATING: Operating
|
||||
- CLOSED_TEMP: Temporarily Closed
|
||||
- SBNO: Standing But Not Operating
|
||||
- CLOSING: Closing
|
||||
- CLOSED_PERM: Permanently Closed
|
||||
- UNDER_CONSTRUCTION: Under Construction
|
||||
- DEMOLISHED: Demolished
|
||||
- RELOCATED: Relocated
|
||||
|
||||
### Track Materials
|
||||
- STEEL: Steel
|
||||
- WOOD: Wood
|
||||
- HYBRID: Hybrid
|
||||
|
||||
### Roller Coaster Types
|
||||
- SITDOWN: Sit Down
|
||||
- INVERTED: Inverted
|
||||
- FLYING: Flying
|
||||
- STANDUP: Stand Up
|
||||
- WING: Wing
|
||||
- DIVE: Dive
|
||||
- FAMILY: Family
|
||||
- WILD_MOUSE: Wild Mouse
|
||||
- SPINNING: Spinning
|
||||
- FOURTH_DIMENSION: 4th Dimension
|
||||
- OTHER: Other
|
||||
|
||||
### Launch Types
|
||||
- CHAIN: Chain Lift
|
||||
- LSM: LSM Launch
|
||||
- HYDRAULIC: Hydraulic Launch
|
||||
- GRAVITY: Gravity
|
||||
- OTHER: Other
|
||||
|
||||
## Implementation Notes
|
||||
|
||||
### History Tracking
|
||||
- Both Ride and RideModel use pghistory for tracking changes
|
||||
- Changes are tracked in corresponding event tables
|
||||
- Event models include display change methods for UI
|
||||
|
||||
### Relationships
|
||||
- Rides belong to Parks and optionally to ParkAreas
|
||||
- Rides can have a RideModel
|
||||
- Rides can have a Manufacturer and Designer
|
||||
- RideModels belong to Manufacturers
|
||||
- Rides have polymorphic relationships with Photos and Reviews
|
||||
|
||||
### Laravel Implementation Plan
|
||||
1. Create migrations for all tables
|
||||
2. Create Enum classes for constants
|
||||
3. Implement Models with relationships
|
||||
4. Add history tracking support
|
||||
5. Create Livewire components for CRUD operations
|
||||
6. Implement views and forms
|
||||
7. Add validation rules
|
||||
8. Create factories and seeders for testing
|
||||
101
memory-bank/models/ReviewModels.md
Normal file
101
memory-bank/models/ReviewModels.md
Normal file
@@ -0,0 +1,101 @@
|
||||
# Review System Models
|
||||
|
||||
## Review Model
|
||||
Represents user reviews for rides in the system.
|
||||
|
||||
### Properties
|
||||
- `id` (int) - Primary key
|
||||
- `ride_id` (int) - Foreign key to rides table
|
||||
- `user_id` (int) - Foreign key to users table
|
||||
- `rating` (int) - Rating from 1 to 5
|
||||
- `title` (string, nullable) - Optional review title
|
||||
- `content` (text) - Review content
|
||||
- `status` (enum) - ReviewStatus enum value
|
||||
- `moderated_at` (timestamp) - When review was moderated
|
||||
- `moderated_by` (int) - Foreign key to users table (moderator)
|
||||
- `helpful_votes_count` (int) - Counter cache for helpful votes
|
||||
|
||||
### Relationships
|
||||
- `ride` - BelongsTo relationship to Ride model
|
||||
- `user` - BelongsTo relationship to User model
|
||||
- `moderator` - BelongsTo relationship to User model
|
||||
- `helpfulVotes` - HasMany relationship to HelpfulVote model
|
||||
|
||||
### Scopes
|
||||
- `pending()` - Reviews awaiting moderation
|
||||
- `approved()` - Approved reviews
|
||||
- `rejected()` - Rejected reviews
|
||||
- `byRide()` - Filter by ride
|
||||
- `byUser()` - Filter by user
|
||||
|
||||
### Methods
|
||||
- `approve()` - Approve the review
|
||||
- `reject()` - Reject the review
|
||||
- `moderate()` - General moderation method
|
||||
- `toggleHelpfulVote()` - Toggle helpful vote from a user
|
||||
|
||||
## HelpfulVote Model
|
||||
Represents users marking reviews as helpful.
|
||||
|
||||
### Properties
|
||||
- `id` (int) - Primary key
|
||||
- `review_id` (int) - Foreign key to reviews table
|
||||
- `user_id` (int) - Foreign key to users table
|
||||
- `created_at` (timestamp) - When vote was cast
|
||||
|
||||
### Relationships
|
||||
- `review` - BelongsTo relationship to Review model
|
||||
- `user` - BelongsTo relationship to User model
|
||||
|
||||
### Methods
|
||||
- `toggle()` - Toggle vote status
|
||||
|
||||
## Database Considerations
|
||||
|
||||
### Indexes
|
||||
1. Reviews Table:
|
||||
- Primary Key: id
|
||||
- Foreign Keys: ride_id, user_id, moderated_by
|
||||
- Composite: [ride_id, user_id] (unique)
|
||||
- Indexes: [ride_id, status], [user_id, created_at], status
|
||||
|
||||
2. Helpful Votes Table:
|
||||
- Primary Key: id
|
||||
- Foreign Keys: review_id, user_id
|
||||
- Composite: [review_id, user_id] (unique)
|
||||
- Indexes: [user_id, created_at]
|
||||
|
||||
### Constraints
|
||||
1. Reviews:
|
||||
- One review per ride per user
|
||||
- Rating must be between 1 and 5
|
||||
- Status must be valid enum value
|
||||
- Content is required
|
||||
|
||||
2. Helpful Votes:
|
||||
- One vote per review per user
|
||||
- Cascading deletes with review
|
||||
|
||||
## Usage Examples
|
||||
|
||||
```php
|
||||
// Create a review
|
||||
$review = Review::create([
|
||||
'ride_id' => $ride->id,
|
||||
'user_id' => Auth::id(),
|
||||
'rating' => 5,
|
||||
'title' => 'Great ride!',
|
||||
'content' => 'This was amazing...',
|
||||
]);
|
||||
|
||||
// Toggle helpful vote
|
||||
$review->toggleHelpfulVote(Auth::id());
|
||||
|
||||
// Moderate a review
|
||||
$review->moderate(ReviewStatus::APPROVED, Auth::id());
|
||||
|
||||
// Get ride's approved reviews
|
||||
$reviews = $ride->reviews()->approved()->latest()->get();
|
||||
|
||||
// Get user's helpful votes
|
||||
$votes = $user->helpfulVotes()->with('review')->get();
|
||||
97
memory-bank/models/RideEnums.md
Normal file
97
memory-bank/models/RideEnums.md
Normal file
@@ -0,0 +1,97 @@
|
||||
# Ride System Enums Documentation
|
||||
|
||||
## Overview
|
||||
The Rides system uses several enum classes to maintain consistent data and provide type safety for various ride attributes. All enums follow a consistent pattern with common helper methods for values, labels, and options.
|
||||
|
||||
## Implementation Details
|
||||
|
||||
### 1. RideCategory
|
||||
- **Purpose**: Categorizes different types of rides
|
||||
- **Location**: `app/Enums/RideCategory.php`
|
||||
- **Values**:
|
||||
- `SELECT` (''): Default selection prompt
|
||||
- `ROLLER_COASTER` ('RC'): Roller coasters
|
||||
- `DARK_RIDE` ('DR'): Dark rides
|
||||
- `FLAT_RIDE` ('FR'): Flat rides
|
||||
- `WATER_RIDE` ('WR'): Water rides
|
||||
- `TRANSPORT` ('TR'): Transport rides
|
||||
- `OTHER` ('OT'): Other ride types
|
||||
|
||||
### 2. RideStatus
|
||||
- **Purpose**: Tracks operational status of rides
|
||||
- **Location**: `app/Enums/RideStatus.php`
|
||||
- **Values**:
|
||||
- `SELECT` (''): Default selection prompt
|
||||
- `OPERATING`: Currently operating
|
||||
- `CLOSED_TEMP`: Temporarily closed
|
||||
- `SBNO`: Standing but not operating
|
||||
- `CLOSING`: Scheduled for closure
|
||||
- `CLOSED_PERM`: Permanently closed
|
||||
- `UNDER_CONSTRUCTION`: Under construction
|
||||
- `DEMOLISHED`: Demolished
|
||||
- `RELOCATED`: Relocated
|
||||
- **Features**:
|
||||
- Includes post-closing status handling
|
||||
- Helper methods for filtering post-closing statuses
|
||||
|
||||
### 3. TrackMaterial
|
||||
- **Purpose**: Specifies roller coaster track material
|
||||
- **Location**: `app/Enums/TrackMaterial.php`
|
||||
- **Values**:
|
||||
- `STEEL`: Steel tracks
|
||||
- `WOOD`: Wooden tracks
|
||||
- `HYBRID`: Hybrid construction
|
||||
|
||||
### 4. RollerCoasterType
|
||||
- **Purpose**: Defines specific roller coaster configurations
|
||||
- **Location**: `app/Enums/RollerCoasterType.php`
|
||||
- **Values**:
|
||||
- `SITDOWN`: Traditional sit-down coaster
|
||||
- `INVERTED`: Inverted coaster
|
||||
- `FLYING`: Flying coaster
|
||||
- `STANDUP`: Stand-up coaster
|
||||
- `WING`: Wing coaster
|
||||
- `DIVE`: Dive coaster
|
||||
- `FAMILY`: Family coaster
|
||||
- `WILD_MOUSE`: Wild Mouse style
|
||||
- `SPINNING`: Spinning coaster
|
||||
- `FOURTH_DIMENSION`: 4th Dimension coaster
|
||||
- `OTHER`: Other configurations
|
||||
|
||||
### 5. LaunchType
|
||||
- **Purpose**: Specifies ride launch mechanism
|
||||
- **Location**: `app/Enums/LaunchType.php`
|
||||
- **Values**:
|
||||
- `CHAIN`: Traditional chain lift
|
||||
- `LSM`: Linear Synchronous Motor launch
|
||||
- `HYDRAULIC`: Hydraulic launch system
|
||||
- `GRAVITY`: Gravity-powered launch
|
||||
- `OTHER`: Other launch types
|
||||
|
||||
## Common Features
|
||||
All enum classes include:
|
||||
1. String-backed values for database storage
|
||||
2. Human-readable labels via `label()` method
|
||||
3. Helper methods:
|
||||
- `values()`: Get all enum values
|
||||
- `labels()`: Get all human-readable labels
|
||||
- `options()`: Get value-label pairs for forms
|
||||
|
||||
## Usage Notes
|
||||
1. All enums maintain exact parity with Django choices
|
||||
2. Used in models for type validation
|
||||
3. Support form select options generation
|
||||
4. Enable consistent validation rules
|
||||
5. Provide clean database values
|
||||
|
||||
## Design Decisions
|
||||
1. Used PHP 8.1 enum feature for type safety
|
||||
2. Maintained consistent method names across all enums
|
||||
3. Added helper methods to simplify form handling
|
||||
4. Included blank/select options where needed
|
||||
5. Used string backing for database compatibility
|
||||
|
||||
## Related Files
|
||||
- `app/Models/Ride.php` (uses RideCategory, RideStatus)
|
||||
- `app/Models/RollerCoasterStats.php` (uses TrackMaterial, RollerCoasterType, LaunchType)
|
||||
- Future Livewire components for ride forms
|
||||
141
memory-bank/models/RideModels.md
Normal file
141
memory-bank/models/RideModels.md
Normal file
@@ -0,0 +1,141 @@
|
||||
# Ride System Models Documentation
|
||||
|
||||
## Overview
|
||||
The rides system is implemented through a set of interconnected Eloquent models that handle different aspects of ride management. The implementation maintains feature parity with the Django original while leveraging Laravel's conventions and features.
|
||||
|
||||
## Model Structure
|
||||
|
||||
### RideModel
|
||||
- **Purpose**: Templates for specific ride types/products
|
||||
- **Key Features**:
|
||||
- Manufacturer relationship
|
||||
- Category type from RideCategory enum
|
||||
- Has many Rides
|
||||
- Full name accessor for manufacturer + model name
|
||||
- **File**: `app/Models/RideModel.php`
|
||||
|
||||
### Ride
|
||||
- **Purpose**: Individual ride installations at parks
|
||||
- **Key Features**:
|
||||
- Complex relationships to:
|
||||
- Park (required)
|
||||
- ParkArea (optional)
|
||||
- Manufacturer (optional)
|
||||
- Designer (optional)
|
||||
- RideModel (optional)
|
||||
- RollerCoasterStats (optional one-to-one)
|
||||
- Status tracking with dates
|
||||
- Automatic slug generation
|
||||
- Type safety through enums
|
||||
- **File**: `app/Models/Ride.php`
|
||||
|
||||
### RollerCoasterStats
|
||||
- **Purpose**: Extended statistics for roller coaster type rides
|
||||
- **Key Features**:
|
||||
- One-to-one relationship with Ride
|
||||
- Physical measurements with decimal precision
|
||||
- Track material and type enums
|
||||
- Train configuration tracking
|
||||
- Total seats calculation
|
||||
- **File**: `app/Models/RollerCoasterStats.php`
|
||||
|
||||
### Designer
|
||||
- **Purpose**: Track ride designers and their work
|
||||
- **Key Features**:
|
||||
- Basic information storage
|
||||
- Automatic slug generation
|
||||
- Has many relationship to rides
|
||||
- **File**: `app/Models/Designer.php`
|
||||
|
||||
## Key Design Decisions
|
||||
|
||||
### 1. Type Safety
|
||||
- Used PHP 8.1 enums for all constrained choices:
|
||||
- RideCategory
|
||||
- RideStatus
|
||||
- TrackMaterial
|
||||
- RollerCoasterType
|
||||
- LaunchType
|
||||
|
||||
### 2. Data Integrity
|
||||
- Proper foreign key constraints
|
||||
- Appropriate nullOnDelete vs cascadeOnDelete choices
|
||||
- Unique constraints where needed
|
||||
|
||||
### 3. Automatic Features
|
||||
- Slug generation on model creation
|
||||
- Proper cast declarations for:
|
||||
- Dates
|
||||
- Decimals
|
||||
- Enums
|
||||
- Integers
|
||||
|
||||
### 4. Optimization Choices
|
||||
- No timestamps on RollerCoasterStats (reduces overhead)
|
||||
- Appropriate indexes on foreign keys
|
||||
- Efficient relationships setup
|
||||
|
||||
### 5. Laravel Conventions
|
||||
- Followed naming conventions
|
||||
- Used protected properties for configurations
|
||||
- Proper method return type declarations
|
||||
- Relationship method naming
|
||||
|
||||
## Usage Examples
|
||||
|
||||
### Creating a New Ride
|
||||
```php
|
||||
$ride = Ride::create([
|
||||
'name' => 'Thunderbolt',
|
||||
'park_id' => $park->id,
|
||||
'category' => RideCategory::ROLLER_COASTER,
|
||||
'status' => RideStatus::OPERATING,
|
||||
]);
|
||||
```
|
||||
|
||||
### Adding Roller Coaster Stats
|
||||
```php
|
||||
$ride->coasterStats()->create([
|
||||
'height_ft' => 120.5,
|
||||
'track_material' => TrackMaterial::STEEL,
|
||||
'roller_coaster_type' => RollerCoasterType::SITDOWN,
|
||||
]);
|
||||
```
|
||||
|
||||
### Getting Ride with All Relations
|
||||
```php
|
||||
$ride = Ride::with([
|
||||
'park',
|
||||
'parkArea',
|
||||
'manufacturer',
|
||||
'designer',
|
||||
'rideModel',
|
||||
'coasterStats',
|
||||
])->find($id);
|
||||
```
|
||||
|
||||
## Relationship Maps
|
||||
|
||||
### RideModel
|
||||
- ← belongs to → Manufacturer
|
||||
- ← has many → Ride
|
||||
|
||||
### Ride
|
||||
- ← belongs to → Park
|
||||
- ← belongs to → ParkArea
|
||||
- ← belongs to → Manufacturer
|
||||
- ← belongs to → Designer
|
||||
- ← belongs to → RideModel
|
||||
- ← has one → RollerCoasterStats
|
||||
|
||||
### RollerCoasterStats
|
||||
- ← belongs to → Ride
|
||||
|
||||
### Designer
|
||||
- ← has many → Ride
|
||||
|
||||
## Future Enhancements
|
||||
1. Add review relationships
|
||||
2. Implement photo relationships
|
||||
3. Add history tracking
|
||||
4. Consider adding composite indexes for common queries
|
||||
107
memory-bank/models/RidesSchema.md
Normal file
107
memory-bank/models/RidesSchema.md
Normal file
@@ -0,0 +1,107 @@
|
||||
# Rides System Database Schema
|
||||
|
||||
## Overview
|
||||
The rides system uses three primary tables to manage ride data:
|
||||
1. `ride_models` - Templates for specific ride types/models
|
||||
2. `rides` - Individual ride installations at parks
|
||||
3. `roller_coaster_stats` - Extended statistics for roller coasters
|
||||
|
||||
## Implementation Details
|
||||
|
||||
### Migration Files
|
||||
- `2024_02_25_194500_create_ride_models_table.php`
|
||||
- `2024_02_25_194600_create_rides_table.php`
|
||||
- `2024_02_25_194700_create_roller_coaster_stats_table.php`
|
||||
|
||||
### RideModels Table
|
||||
- Primary key: `id`
|
||||
- Base information:
|
||||
- `name`: string, required
|
||||
- `description`: text, default empty
|
||||
- `category`: string(2), using RideCategory enum
|
||||
- Relationships:
|
||||
- `manufacturer_id`: nullable foreign key to manufacturers
|
||||
- Constraints:
|
||||
- Unique combination of manufacturer_id and name
|
||||
- Manufacturer can be null (for generic models)
|
||||
|
||||
### Rides Table
|
||||
- Primary key: `id`
|
||||
- Base information:
|
||||
- `name`: string, required
|
||||
- `slug`: string, required
|
||||
- `description`: text, default empty
|
||||
- Relationships:
|
||||
- `park_id`: required foreign key to parks
|
||||
- `park_area_id`: nullable foreign key to park_areas
|
||||
- `manufacturer_id`: nullable foreign key to manufacturers
|
||||
- `designer_id`: nullable foreign key to designers
|
||||
- `ride_model_id`: nullable foreign key to ride_models
|
||||
- Status fields:
|
||||
- `category`: string(2), RideCategory enum
|
||||
- `status`: string(20), RideStatus enum
|
||||
- `post_closing_status`: string(20), nullable
|
||||
- `status_since`: date, nullable
|
||||
- Operational dates:
|
||||
- `opening_date`: date, nullable
|
||||
- `closing_date`: date, nullable
|
||||
- Physical characteristics:
|
||||
- `min_height_in`: unsigned integer, nullable
|
||||
- `max_height_in`: unsigned integer, nullable
|
||||
- `capacity_per_hour`: unsigned integer, nullable
|
||||
- `ride_duration_seconds`: unsigned integer, nullable
|
||||
- User interaction:
|
||||
- `average_rating`: decimal(3,2), nullable
|
||||
- Timestamps: `created_at`, `updated_at`
|
||||
- Indexes:
|
||||
- Unique: [park_id, slug]
|
||||
- Regular: category, status, manufacturer_id, designer_id, ride_model_id
|
||||
|
||||
### RollerCoasterStats Table
|
||||
- Primary key: `id`
|
||||
- Relationship:
|
||||
- `ride_id`: unique foreign key to rides (one-to-one)
|
||||
- Physical measurements:
|
||||
- `height_ft`: decimal(6,2), nullable
|
||||
- `length_ft`: decimal(7,2), nullable
|
||||
- `speed_mph`: decimal(5,2), nullable
|
||||
- `max_drop_height_ft`: decimal(6,2), nullable
|
||||
- Track details:
|
||||
- `inversions`: unsigned integer, default 0
|
||||
- `ride_time_seconds`: unsigned integer, nullable
|
||||
- `track_type`: string, default empty
|
||||
- `track_material`: string(20), using TrackMaterial enum
|
||||
- `roller_coaster_type`: string(20), using RollerCoasterType enum
|
||||
- Train configuration:
|
||||
- `launch_type`: string(20), using LaunchType enum
|
||||
- `train_style`: string, default empty
|
||||
- `trains_count`: unsigned integer, nullable
|
||||
- `cars_per_train`: unsigned integer, nullable
|
||||
- `seats_per_car`: unsigned integer, nullable
|
||||
- Indexes:
|
||||
- track_material
|
||||
- roller_coaster_type
|
||||
- launch_type
|
||||
|
||||
## Design Decisions
|
||||
1. Used one-to-one relationship for roller_coaster_stats to ensure data integrity
|
||||
2. Added proper indexes for common query patterns
|
||||
3. Implemented nullable relationships where appropriate
|
||||
4. Used appropriate data types for numeric values:
|
||||
- decimals for measurements that need precision
|
||||
- integers for whole number counts
|
||||
5. Added proper cascading rules:
|
||||
- rides cascade delete with park
|
||||
- roller_coaster_stats cascade with ride
|
||||
- other relationships set to nullOnDelete for safety
|
||||
|
||||
## Migration Order
|
||||
The migrations are ordered to respect foreign key constraints:
|
||||
1. ride_models (depends on manufacturers)
|
||||
2. rides (depends on parks, park_areas, manufacturers, designers, ride_models)
|
||||
3. roller_coaster_stats (depends on rides)
|
||||
|
||||
## Related Files
|
||||
- Enum classes in app/Enums/
|
||||
- Model classes (to be implemented)
|
||||
- Feature documentation in memory-bank/features/RidesManagement.md
|
||||
Reference in New Issue
Block a user