<?php
defined('_JEXEC') or die;

use Joomla\CMS\Factory;

class ModAgendaPimpinanHelper
{
    /**
     * Ambil agenda terbaru yang publish.
     *
     * Default tabel: #__agenda_pimpinan
     * Jika tabel component Anda berbeda, ubah di sini.
     */
    public static function getItems($params): array
    {
        $db    = Factory::getDbo();
        $limit = (int) $params->get('limit', 5);

        $query = $db->getQuery(true)
            ->select([
                $db->quoteName('id'),
                $db->quoteName('title'),
                $db->quoteName('tanggal'),
                $db->quoteName('lokasi'),
                $db->quoteName('jenis_acara'),
            ])
            ->from($db->quoteName('#__agenda_pimpinan_items'))
            ->where($db->quoteName('state') . ' = 1')
            ->order($db->quoteName('tanggal') . ' DESC');

        $db->setQuery($query, 0, $limit);

        return $db->loadObjectList() ?: [];
    }
}
