<?php

declare(strict_types=1);

namespace KupShop\AdminBundle\Admin\Tabs\Admins;

use KupShop\AdminBundle\Admin\WindowTab;
use Query\Operator;

class AdminSignInTab extends WindowTab
{
    protected $title = 'flapAdminSignIn';

    protected $template = 'window/admins.sign-in.tpl';

    public static function getTypes()
    {
        return [
            'admins' => 0,
        ];
    }

    public function getLabel()
    {
        return translate('flapSignIn', 'admins');
    }

    public function handleGenerateAdminToken(): void
    {
        sqlQueryBuilder()
            ->update('admins')
            ->directValues(['token' => $this->window->generateAdminToken()])
            ->where(Operator::equals(['id' => $this->getID()]))
            ->execute();

        $this->window->returnOK();
    }
}
