public function getModel($name = null)
{
if (!empty($name)) {
$modelName = $name;
} elseif (!empty($this->defaultModel)) {
$modelName = $this->defaultModel;
} else {
$modelName = $this->name;
}
if (!array_key_exists($modelName, $this->modelInstances)) {
throw new ModelNotFound($modelName, $this->name);
}
return $this->modelInstances[$modelName];
}