When a model has a relationship with another model $model->hasMany(...)
, how can I call a function to perform some operation on fetched results ?
Example:
public function initlialize()
{
$this->hasMany('primaryKey', RelatedModel::class, 'refPrimaryKey', [
'alias' => 'somealias',
'callback' => 'some_method_in_related_model'
]);
}
How to obtain such functionality ?