<?php

namespace Database\Seeders;

use App\Enums\RoleSlug;
use App\Models\Role;
use App\Models\User;
use Illuminate\Database\Seeder;

class AdminUserSeeder extends Seeder
{
    public function run(): void
    {
        if (app()->isProduction()) {
            return;
        }

        User::query()->updateOrCreate(
            ['email' => 'admin@royaldevelopers.test'],
            [
                'name' => 'Royal Admin',
                'password' => 'password',
                'role_id' => Role::query()->firstOrCreate(
                    ['slug' => RoleSlug::Admin],
                    [
                        'name' => RoleSlug::Admin->label(),
                        'description' => RoleSlug::Admin->description(),
                    ],
                )->id,
                'email_verified_at' => now(),
            ],
        );
    }
}
