feat: Implement rides management with CRUD functionality

- Added rides index view with search and filter options.
- Created rides show view to display ride details.
- Implemented API routes for rides.
- Developed authentication routes for user registration, login, and email verification.
- Created tests for authentication, email verification, password reset, and user profile management.
- Added feature tests for rides and operators, including creation, updating, deletion, and searching.
- Implemented soft deletes and caching for rides and operators.
- Enhanced manufacturer and operator model tests for various functionalities.
This commit is contained in:
pacnpal
2025-06-19 22:34:10 -04:00
parent 86263db9d9
commit cc33781245
148 changed files with 14026 additions and 2482 deletions

View File

@@ -6,10 +6,11 @@ use App\Traits\HasSlugHistory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\SoftDeletes;
class Manufacturer extends Model
{
use HasFactory, HasSlugHistory;
use HasFactory, HasSlugHistory, SoftDeletes;
/**
* The attributes that are mass assignable.
@@ -24,15 +25,29 @@ class Manufacturer extends Model
'description',
'total_rides',
'total_roller_coasters',
'is_active',
];
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'total_rides' => 'integer',
'total_roller_coasters' => 'integer',
'is_active' => 'boolean',
'created_at' => 'datetime',
'updated_at' => 'datetime',
'deleted_at' => 'datetime',
];
/**
* Get the rides manufactured by this company.
* Note: This relationship will be properly set up when we implement the Rides system.
*/
public function rides(): HasMany
{
return $this->hasMany(Ride::class);
return $this->hasMany(Ride::class, 'manufacturer_id');
}
/**
@@ -42,7 +57,7 @@ class Manufacturer extends Model
{
$this->total_rides = $this->rides()->count();
$this->total_roller_coasters = $this->rides()
->where('type', 'roller_coaster')
->where('category', 'RC')
->count();
$this->save();
}
@@ -88,6 +103,22 @@ class Manufacturer extends Model
return $query->where('total_roller_coasters', '>', 0);
}
/**
* Scope a query to only include active manufacturers.
*/
public function scopeActive($query)
{
return $query->where('is_active', true);
}
/**
* Scope a query for optimized loading with statistics.
*/
public function scopeOptimized($query)
{
return $query->select(['id', 'name', 'slug', 'total_rides', 'total_roller_coasters', 'is_active']);
}
/**
* Get the route key for the model.
*/