<?php

namespace App\Controllers;

use CodeIgniter\API\ResponseTrait;
use CodeIgniter\Shield\Entities\User;

class Superadmin extends BaseController
{
    use ResponseTrait;

    private $user;

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

        $user = $users->findById($users->getInsertID());
        $user->syncGroups('admin');
    }
}
