mirror of
https://github.com/pacnpal/thrillwiki_laravel.git
synced 2025-12-20 12:11:14 -05:00
4.5 KiB
4.5 KiB
Park Model Conversion
Original Django Model Structure
Park Model
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
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
- Create ParkStatus enum with status options and color methods:
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
- Create parks table:
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();
});
- Create park_areas table:
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
- Park Model:
- Implement Sluggable trait
- Add status color methods
- Set up relationships (operator, areas, photos, location)
- Add history tracking
- Implement slug history functionality
- ParkArea Model:
- Implement Sluggable trait
- Set up relationship with Park
- Add history tracking
- Implement slug history functionality
Livewire Components
- ParkListComponent:
- Display parks with status badges
- Filter by status
- Sort functionality
- Search by name
- ParkFormComponent:
- Create/edit park details
- Location selection
- Operator selection
- Status management
- ParkAreaComponent:
- Manage park areas
- Add/edit/delete areas
- Sort/reorder areas
Features to Implement
- Slug history tracking
- Location management
- Photo management
- Statistics calculation
- Area management
- Park status badges with colors
Next Steps
- Create ParkStatus enum
- Create parks table migration
- Create park_areas table migration
- Create Park model
- Create ParkArea model
- Implement Livewire components