<?php

namespace Database\Seeders;

use App\Models\Event;
use App\Models\User;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;

class UserSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        // Test User (normaler User)
        $normalUser = User::create([
            'name' => 'Max Mustermann',
            'email' => 'user@example.com',
            'password' => Hash::make('password123'),
            'role' => 'user',
            'email_verified_at' => now(),
        ]);

        // Test Organizer
        $organizer = User::create([
            'name' => 'Erika Veranstalter',
            'email' => 'organizer@example.com',
            'password' => Hash::make('password123'),
            'role' => 'organizer',
            'email_verified_at' => now(),
        ]);

        // Admin User
        $admin = User::create([
            'name' => 'Admin User',
            'email' => 'admin@example.com',
            'password' => Hash::make('password123'),
            'role' => 'admin',
            'email_verified_at' => now(),
        ]);

        // Der Organizer erstellt einige Events
        Event::whereIn('id', [1, 2, 3])->update(['created_by' => $organizer->id]);

        // Der normale User speichert einige Events als Favorit
        $normalUser->favoriteEvents()->attach([1, 2, 4, 5]);
    }
}
