I want to change automatically the data returns from the model in CodeIgniter 4.
That’s what comes to my mind, but it’s not works:
class UserModel extends Model {
protected $afterFind = ['getImage'];
protected function getImage(array $data) {
if ($data['user_image'] == 0) {
$data['user_image'] = "New Value";
}
return $data;
}
}
Anyone have an idea how to do that?
Thanks.