<?php


use apexl\Io\modules\user\entities\userEntity;
use apexl\Io\modules\user\enums\permissions\User;
use apexl\Io\modules\user\enums\Role;
use Phinx\Seed\AbstractSeed;

class UserSeeder extends AbstractSeed
{
    /**
     * Run Method.
     *
     * Write your database seeder using this method.
     *
     * More information on writing seeders is available here:
     * https://book.cakephp.org/phinx/0/en/seeding.html
     */
    public function run(): void
    {
        userEntity::factory()->create([
            'id' => 2,
            'first_name' => 'Anonymous',
            'last_name' => 'User',
            'active' => true,
            'email' => 'noemail@anon',
            'created' => time(),
        ])->addPermission(User::CAN_REGISTER);

        userEntity::factory()->create([
            'id' => 1,
            'first_name' => 'Superadmin',
            'last_name' => 'User',
            'active' => 1,
            'email' => 'admin@apexlstudios.com',
            'created' => time(),
        ])->addRole(Role::SUPER_ADMINISTRATOR->value);

        $this->execute('update users set id = 0 where id = 2');
    }
}
