Adding views of stacks, manufacturers lists
This commit is contained in:
75
admin/src/Model/ManufacturersModel.php
Normal file
75
admin/src/Model/ManufacturersModel.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Depot.Administrator
|
||||
* @subpackage com_depot
|
||||
* @author Thomas Kuschel <thomas@kuschel.at>
|
||||
* @copyright (C) 2023 KW4NZ, <https://www.kuschel.at>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.md
|
||||
* @since 0.9.3
|
||||
*/
|
||||
|
||||
namespace KW4NZ\Component\Depot\Administrator\Model;
|
||||
|
||||
use Joomla\CMS\MVC\Model\ListModel;
|
||||
use Joomla\CMS\Table\Table;
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
class ManufacturersModel extends ListModel
|
||||
{
|
||||
/**
|
||||
* Build an SQL query to load the list data.
|
||||
*
|
||||
* @return \Joomla\Database\DatabaseQuery
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function getListQuery()
|
||||
{
|
||||
$db = $this->getDatabase();
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
|
||||
// $query->select('*')
|
||||
// ->from($db->quoteName('#__depot', 'd'));
|
||||
|
||||
// order by
|
||||
// $query->order('d.id ASC');
|
||||
// if (true) {
|
||||
// return $query;
|
||||
// }
|
||||
|
||||
// select the required fields from the table
|
||||
$query->select(
|
||||
$this->getState(
|
||||
'list.select',
|
||||
[
|
||||
$db->quoteName('m.id'),
|
||||
$db->quoteName('m.name_short'),
|
||||
$db->quoteName('m.name_long'),
|
||||
$db->quoteName('m.alias'),
|
||||
$db->quoteName('m.description'),
|
||||
]
|
||||
)
|
||||
)
|
||||
->select(
|
||||
[
|
||||
$db->quoteName('u.name', 'creator'),
|
||||
]
|
||||
)
|
||||
->from($db->quoteName('#__depot_manufacturer', 'm'))
|
||||
->join('LEFT', $db->quoteName('#__users', 'u'), $db->quoteName('u.id') . ' = ' . $db->quoteName('m.checked_out'));
|
||||
|
||||
// Filter by published state
|
||||
$published = (string) $this->getState('filter.published');
|
||||
if (is_numeric($published)) {
|
||||
$published = (int) $published;
|
||||
$query->where($db->quoteName('m.state') . ' = :published')
|
||||
->bind(':published', $published, ParameterType::INTEGER);
|
||||
} elseif ($published === '') {
|
||||
$query->where($db->quoteName('m.state') . ' IN (0, 1)');
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user