This is my getItem (J6) in a single record model example. Hope this helps.
/**
* Method to get an object.
* @param integer $id The id of the object to get.
* @return mixed Object on success, false on failure.
* @throws Exception
*/
public function getItem($id = null)
{
if ($this->_item === null) {
$this->_item = false;
if (empty($id)) {
$id = $this->getState('application.id');
}
// Get a level row instance.
$table = $this->getTable();
// Attempt to load the row.
if ($table->load($id)) {
// Check published state.
if ($published = $this->getState('filter.published')) {
if (isset($table->state) && $table->state != $published) {
throw new \Exception(Text::_('COM_MYCOMPONENT_ITEM_NOT_LOADED'), 403);
}
}
// Convert the Table to a clean Object.
$properties = $table->getProperties(1);
$this->_item = ArrayHelper::toObject($properties, 'stdClass');
}
if (empty($this->_item)) {
throw new \Exception(Text::_('COM_MYCOMPONENT_ITEM_NOT_LOADED'), 404);
}
}
if (isset($this->_item->created_by)) {
$this->_item->created_by_name = MycomponentHelper::getSpecificUser($this->_item->created_by)->name;
}
if (isset($this->_item->modified_by)) {
$this->_item->modified_by_name = MycomponentHelper::getSpecificUser($this->_item->modified_by)->name;
}
return $this->_item;
}
As for params, I get these from the populateState function.
// Load the parameters.
$params = Factory::getApplication('com_mycomponent')->getParams();
$params_array = $params->toArray();