Actually there are no any explicit declaration of the data members in the Model, like the code below.
I think I cant't use getter
or setter
to change the data members. How to deal with afterFetch()
?
class Companies extends AbstractModel
{
/**
* Initialize relationships and model properties
*/
public function initialize()
{
$this->setSource('co_companies');
$this->hasMany(
'id',
Individuals::class,
'companyId',
[
'alias' => Relationships::INDIVIDUALS,
'reusable' => true,
]
);
parent::initialize();
}
/**
* Model filters
*
* @return array<string,string>
*/
public function getModelFilters(): array
{
return [
'id' => Filter::FILTER_ABSINT,
'name' => Filter::FILTER_STRING,
'address' => Filter::FILTER_STRING,
'city' => Filter::FILTER_STRING,
'phone' => Filter::FILTER_STRING,
];
}
}
You can use afterFetch() function in the Model Class and there convert your data: unserialize, decode form JSON etc.