<?php

function smarty_function_get_faq($params, &$smarty)
{
    $faq = sqlQueryBuilder()
        ->select('*')
        ->from('kupshop_shared.faq')
        ->where(\Query\Operator::equals(['visible' => 1]))
        ->orderBy('rand()')
        ->setMaxResults(1)
        ->execute()->fetch();

    if (!empty($params['assign'])) {
        $smarty->assign($params['assign'], $faq);
    } else {
        return $faq;
    }
}
