mirror of
https://github.com/pacnpal/thrillwiki_laravel.git
synced 2025-12-20 12:11:14 -05:00
164 lines
4.5 KiB
Markdown
164 lines
4.5 KiB
Markdown
# Park Model Conversion
|
|
|
|
## Original Django Model Structure
|
|
|
|
### Park Model
|
|
```python
|
|
class Park(TrackedModel):
|
|
# Status choices
|
|
STATUS_CHOICES = [
|
|
("OPERATING", "Operating"),
|
|
("CLOSED_TEMP", "Temporarily Closed"),
|
|
("CLOSED_PERM", "Permanently Closed"),
|
|
("UNDER_CONSTRUCTION", "Under Construction"),
|
|
("DEMOLISHED", "Demolished"),
|
|
("RELOCATED", "Relocated"),
|
|
]
|
|
|
|
# Basic info
|
|
name = models.CharField(max_length=255)
|
|
slug = models.SlugField(max_length=255, unique=True)
|
|
description = models.TextField(blank=True)
|
|
status = models.CharField(max_length=20, choices=STATUS_CHOICES, default="OPERATING")
|
|
|
|
# Location fields (GenericRelation)
|
|
location = GenericRelation(Location)
|
|
|
|
# Details
|
|
opening_date = models.DateField(null=True, blank=True)
|
|
closing_date = models.DateField(null=True, blank=True)
|
|
operating_season = models.CharField(max_length=255, blank=True)
|
|
size_acres = models.DecimalField(max_digits=10, decimal_places=2, null=True)
|
|
website = models.URLField(blank=True)
|
|
|
|
# Statistics
|
|
average_rating = models.DecimalField(max_digits=3, decimal_places=2, null=True)
|
|
ride_count = models.IntegerField(null=True)
|
|
coaster_count = models.IntegerField(null=True)
|
|
|
|
# Relationships
|
|
operator = models.ForeignKey(Operator, SET_NULL, null=True, related_name="parks")
|
|
photos = GenericRelation(Photo)
|
|
```
|
|
|
|
### ParkArea Model
|
|
```python
|
|
class ParkArea(TrackedModel):
|
|
park = models.ForeignKey(Park, CASCADE, related_name="areas")
|
|
name = models.CharField(max_length=255)
|
|
slug = models.SlugField(max_length=255)
|
|
description = models.TextField(blank=True)
|
|
opening_date = models.DateField(null=True, blank=True)
|
|
closing_date = models.DateField(null=True, blank=True)
|
|
```
|
|
|
|
## Laravel Implementation Plan
|
|
|
|
### Enums
|
|
1. Create ParkStatus enum with status options and color methods:
|
|
```php
|
|
enum ParkStatus: string {
|
|
case OPERATING = 'OPERATING';
|
|
case CLOSED_TEMP = 'CLOSED_TEMP';
|
|
case CLOSED_PERM = 'CLOSED_PERM';
|
|
case UNDER_CONSTRUCTION = 'UNDER_CONSTRUCTION';
|
|
case DEMOLISHED = 'DEMOLISHED';
|
|
case RELOCATED = 'RELOCATED';
|
|
}
|
|
```
|
|
|
|
### Database Migrations
|
|
|
|
1. Create parks table:
|
|
```php
|
|
Schema::create('parks', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->string('name');
|
|
$table->string('slug')->unique();
|
|
$table->text('description')->nullable();
|
|
$table->string('status', 20);
|
|
|
|
// Details
|
|
$table->date('opening_date')->nullable();
|
|
$table->date('closing_date')->nullable();
|
|
$table->string('operating_season')->nullable();
|
|
$table->decimal('size_acres', 10, 2)->nullable();
|
|
$table->string('website')->nullable();
|
|
|
|
// Statistics
|
|
$table->decimal('average_rating', 3, 2)->nullable();
|
|
$table->integer('ride_count')->nullable();
|
|
$table->integer('coaster_count')->nullable();
|
|
|
|
// Foreign keys
|
|
$table->foreignId('operator_id')->nullable()->constrained('operators')->nullOnDelete();
|
|
|
|
$table->timestamps();
|
|
});
|
|
```
|
|
|
|
2. Create park_areas table:
|
|
```php
|
|
Schema::create('park_areas', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->foreignId('park_id')->constrained()->cascadeOnDelete();
|
|
$table->string('name');
|
|
$table->string('slug');
|
|
$table->text('description')->nullable();
|
|
$table->date('opening_date')->nullable();
|
|
$table->date('closing_date')->nullable();
|
|
$table->timestamps();
|
|
|
|
$table->unique(['park_id', 'slug']);
|
|
});
|
|
```
|
|
|
|
### Models
|
|
|
|
1. Park Model:
|
|
- Implement Sluggable trait
|
|
- Add status color methods
|
|
- Set up relationships (operator, areas, photos, location)
|
|
- Add history tracking
|
|
- Implement slug history functionality
|
|
|
|
2. ParkArea Model:
|
|
- Implement Sluggable trait
|
|
- Set up relationship with Park
|
|
- Add history tracking
|
|
- Implement slug history functionality
|
|
|
|
### Livewire Components
|
|
|
|
1. ParkListComponent:
|
|
- Display parks with status badges
|
|
- Filter by status
|
|
- Sort functionality
|
|
- Search by name
|
|
|
|
2. ParkFormComponent:
|
|
- Create/edit park details
|
|
- Location selection
|
|
- Operator selection
|
|
- Status management
|
|
|
|
3. ParkAreaComponent:
|
|
- Manage park areas
|
|
- Add/edit/delete areas
|
|
- Sort/reorder areas
|
|
|
|
### Features to Implement
|
|
1. Slug history tracking
|
|
2. Location management
|
|
3. Photo management
|
|
4. Statistics calculation
|
|
5. Area management
|
|
6. Park status badges with colors
|
|
|
|
### Next Steps
|
|
1. [ ] Create ParkStatus enum
|
|
2. [ ] Create parks table migration
|
|
3. [ ] Create park_areas table migration
|
|
4. [ ] Create Park model
|
|
5. [ ] Create ParkArea model
|
|
6. [ ] Implement Livewire components |