mirror of
https://github.com/pacnpal/thrillwiki_laravel.git
synced 2025-12-20 09:11:10 -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:
@@ -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');
|
||||
}
|
||||
};
|
||||
57
database/migrations/2024_02_25_194600_create_rides_table.php
Normal file
57
database/migrations/2024_02_25_194600_create_rides_table.php
Normal 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');
|
||||
}
|
||||
};
|
||||
@@ -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');
|
||||
}
|
||||
};
|
||||
@@ -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');
|
||||
}
|
||||
};
|
||||
@@ -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');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user