<?php

namespace App\Controllers;

use CodeIgniter\Shield\Entities\User;
use App\Models\Usermodel;

class Supercontroller extends BaseController
{
    public function index()
    {
        $user_provider = auth()->getProvider();
        $user = new User([
            'username' => 'admin',
            'email'    => 'admin@gmail.com',
            'password' => '12345678',
        ]);

        if($user_provider->save($user)){
            $id_user = $user_provider->getInsertID();
            $user = $user_provider->findById($id_user);
            $user->addgroup("admin");

            $request = [
                'nama' => 'Admin',
                'email' => 'admin@gmail.com',
                'level' => 'admin'
            ];
            $request['id_auth'] = $id_user;
            $tmodel = new Usermodel();
            $tmodel->insert($request, false);
        }
    }
}
