<?php

namespace App\Config;

use App\Interfaces\UserRequest;
use App\Models\StatusAkun;
use App\Models\UserRole;
use App\Repositories\UserRepo;

class UserSeeder
{

  private UserRepo $userRepo;
  public function __construct()
  {
    $this->userRepo = new UserRepo();
  }

  public function init()
  {

    $user = $this->userRepo->getByUsername('admin');
    if ($user !== null) return;

    $user = new UserRequest();
    $user->create(
      nama: "Admin",
      username: "admin",
      password: "admin123",
      email: "admin@gmail.com",
      noTelepon: "08637483728",
      role: UserRole::ADMIN,
      divisiId: null,
      statusAkun: StatusAkun::AKTIF,
      spesialisasi: null
    );

    $user->hashPassword();

    $this->userRepo->save($user);
  }
}
