mirror of
https://github.com/pacnpal/thrillwiki_laravel.git
synced 2025-12-20 10:31:11 -05:00
82 lines
2.3 KiB
Markdown
82 lines
2.3 KiB
Markdown
# Operator Model Conversion
|
|
|
|
## Original Django Model Structure
|
|
|
|
### Company Model (Now Operator)
|
|
```python
|
|
class Company(TrackedModel):
|
|
name = models.CharField(max_length=255)
|
|
slug = models.SlugField(max_length=255, unique=True)
|
|
website = models.URLField(blank=True)
|
|
headquarters = models.CharField(max_length=255, blank=True)
|
|
description = models.TextField(blank=True)
|
|
total_parks = models.IntegerField(default=0)
|
|
total_rides = models.IntegerField(default=0)
|
|
```
|
|
|
|
### Manufacturer Model
|
|
```python
|
|
class Manufacturer(TrackedModel):
|
|
name = models.CharField(max_length=255)
|
|
slug = models.SlugField(max_length=255, unique=True)
|
|
website = models.URLField(blank=True)
|
|
headquarters = models.CharField(max_length=255, blank=True)
|
|
description = models.TextField(blank=True)
|
|
total_rides = models.IntegerField(default=0)
|
|
total_roller_coasters = models.IntegerField(default=0)
|
|
```
|
|
|
|
## Laravel Implementation Plan
|
|
|
|
### Database Migrations
|
|
|
|
1. Create operators table:
|
|
```php
|
|
Schema::create('operators', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->string('name');
|
|
$table->string('slug')->unique();
|
|
$table->string('website')->nullable();
|
|
$table->string('headquarters')->nullable();
|
|
$table->text('description')->nullable();
|
|
$table->integer('total_parks')->default(0);
|
|
$table->integer('total_rides')->default(0);
|
|
$table->timestamps();
|
|
});
|
|
```
|
|
|
|
2. Create manufacturers table:
|
|
```php
|
|
Schema::create('manufacturers', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->string('name');
|
|
$table->string('slug')->unique();
|
|
$table->string('website')->nullable();
|
|
$table->string('headquarters')->nullable();
|
|
$table->text('description')->nullable();
|
|
$table->integer('total_rides')->default(0);
|
|
$table->integer('total_roller_coasters')->default(0);
|
|
$table->timestamps();
|
|
});
|
|
```
|
|
|
|
### Models
|
|
|
|
1. Operator Model:
|
|
- Implement Sluggable trait
|
|
- Add relationships (parks)
|
|
- Add statistics updating methods
|
|
- Add slug history functionality
|
|
|
|
2. Manufacturer Model:
|
|
- Implement Sluggable trait
|
|
- Add relationships (rides)
|
|
- Add statistics updating methods
|
|
- Add slug history functionality
|
|
|
|
### Next Steps
|
|
1. [ ] Create operators table migration
|
|
2. [ ] Create manufacturers table migration
|
|
3. [ ] Create Operator model
|
|
4. [ ] Create Manufacturer model
|
|
5. [ ] Implement statistics update methods |