# User Model Conversion

## Original Django Model Structure

### User Model (extends AbstractUser)
```python
class User(AbstractUser):
    # Custom fields
    user_id = models.CharField(max_length=10, unique=True, editable=False)
    role = models.CharField(max_length=10, choices=['USER', 'MODERATOR', 'ADMIN', 'SUPERUSER'])
    is_banned = models.BooleanField(default=False)
    ban_reason = models.TextField(blank=True)
    ban_date = models.DateTimeField(null=True, blank=True)
    pending_email = models.EmailField(blank=True, null=True)
    theme_preference = models.CharField(max_length=5, choices=['light', 'dark'])
```

### UserProfile Model
```python
class UserProfile:
    profile_id = models.CharField(max_length=10, unique=True, editable=False)
    user = models.OneToOneField(User, related_name='profile')
    display_name = models.CharField(max_length=50, unique=True)
    avatar = models.ImageField(upload_to='avatars/')
    pronouns = models.CharField(max_length=50, blank=True)
    bio = models.TextField(max_length=500, blank=True)
    
    # Social media
    twitter = models.URLField(blank=True)
    instagram = models.URLField(blank=True)
    youtube = models.URLField(blank=True)
    discord = models.CharField(max_length=100, blank=True)
    
    # Stats
    coaster_credits = models.IntegerField(default=0)
    dark_ride_credits = models.IntegerField(default=0)
    flat_ride_credits = models.IntegerField(default=0)
    water_ride_credits = models.IntegerField(default=0)
```

## Laravel Implementation Plan

### Database Migrations

1. Extend users table (`database/migrations/[timestamp]_add_user_fields.php`):
```php
Schema::table('users', function (Blueprint $table) {
    $table->string('user_id', 10)->unique();
    $table->enum('role', ['USER', 'MODERATOR', 'ADMIN', 'SUPERUSER'])->default('USER');
    $table->boolean('is_banned')->default(false);
    $table->text('ban_reason')->nullable();
    $table->timestamp('ban_date')->nullable();
    $table->string('pending_email')->nullable();
    $table->enum('theme_preference', ['light', 'dark'])->default('light');
});
```

2. Create profiles table (`database/migrations/[timestamp]_create_profiles_table.php`):
```php
Schema::create('profiles', function (Blueprint $table) {
    $table->id();
    $table->string('profile_id', 10)->unique();
    $table->foreignId('user_id')->constrained()->onDelete('cascade');
    $table->string('display_name', 50)->unique();
    $table->string('avatar')->nullable();
    $table->string('pronouns', 50)->nullable();
    $table->text('bio')->nullable();
    
    // Social media
    $table->string('twitter')->nullable();
    $table->string('instagram')->nullable();
    $table->string('youtube')->nullable();
    $table->string('discord', 100)->nullable();
    
    // Stats
    $table->integer('coaster_credits')->default(0);
    $table->integer('dark_ride_credits')->default(0);
    $table->integer('flat_ride_credits')->default(0);
    $table->integer('water_ride_credits')->default(0);
    
    $table->timestamps();
});
```

### Model Implementation

1. User Model (`app/Models/User.php`):
- Extend Laravel's base User model
- Add custom attributes
- Add relationship to Profile
- Add role management methods
- Add ban management methods

2. Profile Model (`app/Models/Profile.php`):
- Create new model
- Add relationship to User
- Add avatar handling methods
- Add credit management methods

### Livewire Components
1. ProfileComponent - Handle profile management
2. AvatarUploadComponent - Handle avatar uploads
3. UserSettingsComponent - Handle user settings/preferences
4. UserBanComponent - For moderator use to handle bans

### Services
1. UserService - Business logic for user management
2. ProfileService - Business logic for profile management
3. AvatarService - Handle avatar generation and storage

### Next Steps
1. [ ] Create user fields migration
2. [ ] Create profiles table migration
3. [ ] Enhance User model with new fields and methods
4. [ ] Create Profile model
5. [ ] Implement initial Livewire components for profile management

### Notes
- Will use Laravel's built-in authentication (already scaffolded)
- Email verification will be handled by Laravel's built-in features
- Password reset functionality will use Laravel's default implementation
- Will implement custom avatar generation similar to Django version