aggiunta vista singola circolare
This commit is contained in:
33
site/src/Model/CircolareModel.php
Normal file
33
site/src/Model/CircolareModel.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
namespace Pcrt\Component\Circolari\Site\Model;
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\MVC\Model\ItemModel;
|
||||
|
||||
class CircolareModel extends ItemModel
|
||||
{
|
||||
protected function populateState(): void
|
||||
{
|
||||
$app = Factory::getApplication();
|
||||
$this->setState('circolare.id', (int) $app->input->getInt('id'));
|
||||
parent::populateState();
|
||||
}
|
||||
|
||||
public function getItem($pk = null)
|
||||
{
|
||||
$pk = $pk ?: (int) $this->getState('circolare.id');
|
||||
if (!$pk) return null;
|
||||
|
||||
$db = Factory::getContainer()->get('DatabaseDriver');
|
||||
$q = $db->getQuery(true)
|
||||
->select('*')
|
||||
->from($db->quoteName('#__circolari'))
|
||||
->where($db->quoteName('id') . ' = ' . (int) $pk)
|
||||
->where($db->quoteName('state') . ' = 1');
|
||||
$db->setQuery($q);
|
||||
|
||||
return $db->loadObject();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user