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:
pacnpal
2025-02-25 20:37:19 -05:00
parent 8951e59f49
commit 64b0e90a27
35 changed files with 3157 additions and 1 deletions

View File

@@ -0,0 +1,27 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('ride_models', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->foreignId('manufacturer_id')->nullable()->constrained('manufacturers')->nullOnDelete();
$table->text('description')->default('');
$table->string('category', 2)->default('');
$table->timestamps();
$table->unique(['manufacturer_id', 'name']);
});
}
public function down(): void
{
Schema::dropIfExists('ride_models');
}
};

View File

@@ -0,0 +1,57 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('rides', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('slug');
$table->text('description')->default('');
// Foreign key relationships
$table->foreignId('park_id')->constrained('parks')->cascadeOnDelete();
$table->foreignId('park_area_id')->nullable()->constrained('park_areas')->nullOnDelete();
$table->foreignId('manufacturer_id')->nullable()->constrained('manufacturers')->nullOnDelete();
$table->foreignId('designer_id')->nullable()->constrained('designers')->nullOnDelete();
$table->foreignId('ride_model_id')->nullable()->constrained('ride_models')->nullOnDelete();
// Main attributes
$table->string('category', 2)->default('');
$table->string('status', 20)->default('OPERATING');
$table->string('post_closing_status', 20)->nullable();
$table->date('opening_date')->nullable();
$table->date('closing_date')->nullable();
$table->date('status_since')->nullable();
// Physical characteristics
$table->unsignedInteger('min_height_in')->nullable();
$table->unsignedInteger('max_height_in')->nullable();
$table->unsignedInteger('capacity_per_hour')->nullable();
$table->unsignedInteger('ride_duration_seconds')->nullable();
// Ratings
$table->decimal('average_rating', 3, 2)->nullable();
$table->timestamps();
// Indexes
$table->unique(['park_id', 'slug']);
$table->index('category');
$table->index('status');
$table->index('manufacturer_id');
$table->index('designer_id');
$table->index('ride_model_id');
});
}
public function down(): void
{
Schema::dropIfExists('rides');
}
};

View File

@@ -0,0 +1,48 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('roller_coaster_stats', function (Blueprint $table) {
$table->id();
$table->foreignId('ride_id')->unique()->constrained('rides')->cascadeOnDelete();
// Physical dimensions
$table->decimal('height_ft', 6, 2)->nullable();
$table->decimal('length_ft', 7, 2)->nullable();
$table->decimal('speed_mph', 5, 2)->nullable();
$table->decimal('max_drop_height_ft', 6, 2)->nullable();
// Track characteristics
$table->unsignedInteger('inversions')->default(0);
$table->unsignedInteger('ride_time_seconds')->nullable();
$table->string('track_type')->default('');
$table->string('track_material', 20)->default('STEEL');
$table->string('roller_coaster_type', 20)->default('SITDOWN');
// Launch and train details
$table->string('launch_type', 20)->default('CHAIN');
$table->string('train_style')->default('');
$table->unsignedInteger('trains_count')->nullable();
$table->unsignedInteger('cars_per_train')->nullable();
$table->unsignedInteger('seats_per_car')->nullable();
// No timestamps needed as this table is coupled to rides table
// Indexes
$table->index('track_material');
$table->index('roller_coaster_type');
$table->index('launch_type');
});
}
public function down(): void
{
Schema::dropIfExists('roller_coaster_stats');
}
};

View File

@@ -0,0 +1,53 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use App\Enums\ReviewStatus;
return new class extends Migration
{
public function up(): void
{
Schema::create('reviews', function (Blueprint $table) {
$table->id();
$table->foreignId('ride_id')
->constrained()
->onDelete('cascade');
$table->foreignId('user_id')
->constrained()
->onDelete('cascade');
$table->integer('rating')
->unsigned()
->comment('Rating from 1 to 5');
$table->string('title', 100)
->nullable();
$table->text('content');
$table->string('status')
->default(ReviewStatus::PENDING->value);
$table->timestamp('moderated_at')
->nullable();
$table->foreignId('moderated_by')
->nullable()
->constrained('users')
->nullOnDelete();
$table->integer('helpful_votes_count')
->default(0)
->unsigned();
$table->timestamps();
// Ensure one review per ride per user
$table->unique(['ride_id', 'user_id']);
// Indexes for common queries
$table->index(['ride_id', 'status']);
$table->index(['user_id', 'created_at']);
$table->index('status');
});
}
public function down(): void
{
Schema::dropIfExists('reviews');
}
};

View File

@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('helpful_votes', function (Blueprint $table) {
$table->id();
$table->foreignId('review_id')
->constrained()
->onDelete('cascade');
$table->foreignId('user_id')
->constrained()
->onDelete('cascade');
$table->timestamps();
// Ensure one vote per review per user
$table->unique(['review_id', 'user_id']);
// Index for queries
$table->index(['user_id', 'created_at']);
});
}
public function down(): void
{
Schema::dropIfExists('helpful_votes');
}
};