<?php

namespace Database\Seeders;

use App\Enums\Gender;
use App\Enums\Role;
use App\Models\User;
use App\Models\UserProfile;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;

class UserSeeder extends Seeder
{
    public function run(): void
    {
        DB::transaction(function () {
            $developer = User::factory()->create([
                'email' => 'project.pangestuyoga@gmail.com',
                'username' => 'pangestu',
                'password' => config('auth.password_default'),
            ]);

            UserProfile::factory()->create([
                'user_id' => $developer->id,
                'full_name' => 'Yoga Pangestu',
                'phone_number' => '082121495806',
                'gender' => Gender::MALE->value,
            ]);

            $developer->assignRole(Role::DEVELOPER->value);

            $owner = User::factory()->create([
                'email' => 'owner@gmail.com',
                'username' => 'owner',
                'password' => config('auth.password_default'),
            ]);

            UserProfile::factory()->create([
                'user_id' => $owner->id,
                'full_name' => 'Owner',
                'gender' => Gender::MALE->value,
            ]);

            $owner->assignRole(Role::OWNER->value);
        });
    }
}
