Your IP : 216.73.217.142


Current Path : /var/www/consult-e-syn/public_html/components/com_ats/Model/
Upload File :
Current File : /var/www/consult-e-syn/public_html/components/com_ats/Model/Posts.php

<?php
/**
 * @package   ats
 * @copyright Copyright (c)2011-2022 Nicholas K. Dionysopoulos / Akeeba Ltd
 * @license   GNU General Public License version 3, or later
 */

namespace Akeeba\TicketSystem\Site\Model;

defined('_JEXEC') or die;

use FOF40\Container\Container;

/**
 * Class Posts
 *
 * We simply expose the backend model to the frontend. Since we're using the BasicFactory, there are no security issues,
 * public visitors can't reach this model
 *
 * @package Akeeba\TicketSystem\Site\Model
 */
class Posts extends \Akeeba\TicketSystem\Admin\Model\Posts
{
    public function __construct(Container $container, array $config = array())
    {
        parent::__construct($container, $config);

        $this->with(array('ticket'));
    }

    /**
     * Checks if the post is the first one
     *
     * @param   int   $post_id   Post id
     *
     * @return  bool
     */
    public function isFirstOne($post_id = null)
    {
        if($post_id)
        {
            $this->find($post_id);
        }

        $db = $this->getDbo();
        // Do I have a post previous of this one?
        $query = $db->getQuery(true)
                    ->select('COUNT(*)')
                    ->from('#__ats_posts')
                    ->where('ats_ticket_id = '.$this->ats_ticket_id)
                    ->where('ats_post_id < '.$this->ats_post_id);

        return !($db->setQuery($query)->loadResult());
    }
}