The base model knows how to map an API resource field to a DB field.

This commit is contained in:
Alex Tselegidis 2021-11-03 08:22:27 +01:00
parent c390a6552a
commit ea659ccb9f

View file

@ -178,4 +178,16 @@ class EA_Model extends CI_Model {
return in_array($field, $fields); return in_array($field, $fields);
}, ARRAY_FILTER_USE_KEY); }, ARRAY_FILTER_USE_KEY);
} }
/**
* Get the DB field name based on an API field name.
*
* @param string $api_field API resource key.
*
* @return string|null Returns the column field or null if non found.
*/
public function db_field(string $api_field): ?string
{
return $this->api_resource[$api_field] ?? NULL;
}
} }