For example i have following code:
public function index()
{
return
Model::select(['id', 'some_field', ...// more some fields])
->with('data') // load relation
->paginate(20);
}
How do i format (transform/manipulate on) obtained data from database?
CakePHP ORM have useful method for this -https://book.cakephp.org/3.0/en/orm/query-builder.html#adding-calculated-fields && https://book.cakephp.org/3.0/en/orm/retrieving-data-and-resultsets.html#map-reduce
But i can't find any thing, that can help me to do a same things in Laravel. I can override "toArray" method in a model, but this will affect all application parts (not only an index action in my controller).