<?php

namespace Ministra\Lib;

use Ministra\Lib\bd5c9022e9a9029209e5fd05775ea272\B4291b8d8fa2d898727b1f446db1e661e;
class Advertising
{
    public function __construct()
    {
    }
    public function getMainMini()
    {
        $ad = $this->getMain();
        if (\array_key_exists('text', $ad)) {
            unset($ad['text']);
        }
        return $ad;
    }
    public function getMain()
    {
        $ad = \Ministra\Lib\bd5c9022e9a9029209e5fd05775ea272\B4291b8d8fa2d898727b1f446db1e661e::getInstance()->from('main_page_ad')->get()->all();
        if (\count($ad) > 0) {
            return $ad[0];
        }
    }
    public function setMain($title = '', $text = '', $video_id = 0)
    {
        $rows = \Ministra\Lib\bd5c9022e9a9029209e5fd05775ea272\B4291b8d8fa2d898727b1f446db1e661e::getInstance()->count()->from('main_page_ad')->get()->counter();
        if ($rows > 0) {
            \Ministra\Lib\bd5c9022e9a9029209e5fd05775ea272\B4291b8d8fa2d898727b1f446db1e661e::getInstance()->update('main_page_ad', ['title' => $title, 'text' => $text, 'video_id' => (int) $video_id], []);
        } else {
            \Ministra\Lib\bd5c9022e9a9029209e5fd05775ea272\B4291b8d8fa2d898727b1f446db1e661e::getInstance()->insert('main_page_ad', ['title' => $title, 'text' => $text, 'video_id' => (int) $video_id]);
        }
    }
    public function delMain()
    {
        \Ministra\Lib\bd5c9022e9a9029209e5fd05775ea272\B4291b8d8fa2d898727b1f446db1e661e::getInstance()->query('delete from main_page_ad');
    }
}
