mirror of
https://github.com/pacnpal/thrillwiki_laravel.git
synced 2025-12-20 08:31:09 -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:
79
app/Models/RollerCoasterStats.php
Normal file
79
app/Models/RollerCoasterStats.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\TrackMaterial;
|
||||
use App\Enums\RollerCoasterType;
|
||||
use App\Enums\LaunchType;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class RollerCoasterStats extends Model
|
||||
{
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'ride_id',
|
||||
'height_ft',
|
||||
'length_ft',
|
||||
'speed_mph',
|
||||
'inversions',
|
||||
'ride_time_seconds',
|
||||
'track_type',
|
||||
'track_material',
|
||||
'roller_coaster_type',
|
||||
'max_drop_height_ft',
|
||||
'launch_type',
|
||||
'train_style',
|
||||
'trains_count',
|
||||
'cars_per_train',
|
||||
'seats_per_car',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
protected $casts = [
|
||||
'height_ft' => 'decimal:2',
|
||||
'length_ft' => 'decimal:2',
|
||||
'speed_mph' => 'decimal:2',
|
||||
'max_drop_height_ft' => 'decimal:2',
|
||||
'track_material' => TrackMaterial::class,
|
||||
'roller_coaster_type' => RollerCoasterType::class,
|
||||
'launch_type' => LaunchType::class,
|
||||
'trains_count' => 'integer',
|
||||
'cars_per_train' => 'integer',
|
||||
'seats_per_car' => 'integer',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the ride that owns these statistics.
|
||||
*/
|
||||
public function ride(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Ride::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate total seating capacity.
|
||||
*/
|
||||
public function getTotalSeatsAttribute(): ?int
|
||||
{
|
||||
if ($this->trains_count && $this->cars_per_train && $this->seats_per_car) {
|
||||
return $this->trains_count * $this->cars_per_train * $this->seats_per_car;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user