A getter acts on the value that has been pulled from the database only when the field is requested. This means that the value has already been retrieved by the time the getter fires.
Thanks for answering... Any suggestion of doing this with Eloquent or do you recommend go to Repository Pattern and define All()/ find() /etc...? I really want to stay on Eloquent.
I find a solution that works for my situation and I share it here.
public function newQuery($excludeDeleted = true)
{
return parent::newQuery()->addSelect('*',DB::raw('asText(position) wkt'));
}
// I added $append = ['wkt']; & hidden= ['position']
If you think it could be better let me know
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community