How do i change json response data names like laravel resources

Please i am coming from a laravel background, i am building an app but i would like to change the response values coming from my database table like the way its done in laravel resources. so that future api update can change database values without affecting API dedicated values, thanks for your time guys.

public function toArray($request)
    {
        return [
            'category_id' => $this->id,
            'category_title' => $this->title,
            'category_color' => $this->color,
        ];
    }

I lot of people earlier mentioned adonis-bumblebee for this. I suggest trying that once

2 Likes