input->get('layout')) { $this->context .= '.' . $layout; } // List state information $ordering = empty($ordering) ? 'client.id' : $ordering; parent::populateState($ordering, $direction); } /** * Method to get a store id based on model configuration state. * * @param string $id A prefix for the store id. * * @return string A store id. * * @since 1.0.0 */ protected function getStoreId($id = ''): string { $id .= ':' . $this->getState('filter.search'); return parent::getStoreId($id); } /** * Method to get a DatabaseQuery object for retrieving the data set from a database. * * @return \Joomla\Database\QueryInterface A QueryInterface object to retrieve the data set. * * @throws \Exception * * @since 1.0.0 */ protected function getListQuery(): \Joomla\Database\QueryInterface { $db = $this->getDatabase(); $query = $db->getQuery(true); $query->select(['client.id', 'client.client_name', 'client.client_token', 'client.client_id',]) ->from($db->qn('#__webmasterskaya_oauthserver_clients', 'client')); // Filter by search state $search = $this->getState('filter.search'); if (!empty($search)) { $query->where('client.name LIKE :search') ->bind(':search', $search, ParameterType::STRING); } // Add the list ordering clause $ordering = $this->state->get('list.ordering', 'client.id'); $direction = $this->state->get('list.direction', 'desc'); $query->order($db->escape($ordering) . ' ' . $db->escape($direction)); return $query; } }