<?php

namespace ModulesGarden\ProxmoxAddon\App\UI\IpLog\Providers;

use ModulesGarden\ProxmoxAddon\App\Models\IpLog;
use ModulesGarden\ProxmoxAddon\Core\UI\Interfaces\AdminArea;
use ModulesGarden\ProxmoxAddon\Core\UI\ResponseTemplates\HtmlDataJsonResponse;
use ModulesGarden\ProxmoxAddon\Core\UI\Widget\Forms\DataProviders\BaseModelDataProvider;
use function ModulesGarden\ProxmoxAddon\Core\Helper\sl;

/**
 *
 * Description of RangeVmProvider
 *
 * @author Pawel Kopec <pawelk@modulesgardne.com>
 */
class IpLogProvider extends BaseModelDataProvider implements AdminArea
{

    public function __construct()
    {
        parent::__construct(IpLog::class);
    }


    public function delete()
    {
        parent::delete();
        return (new HtmlDataJsonResponse())->setMessageAndTranslate('IP Log has been deleted successfully');
    }

    public function deleteMass()
    {

        if (!$this->getRequestValue('massActions'))
        {
            return;
        }
        IpLog::destroy($this->getRequestValue('massActions'));
        return (new HtmlDataJsonResponse())->setMessageAndTranslate('The selected enteries have been deleted successfully')
            ->setStatusSuccess()
            ->setCallBackFunction($this->callBackFunction);
    }
}
