Maybe you should look at Eloquent API Resource ( https://laravel.com/docs/9.x/eloquent-resources )
Nov 16, 2022
3
Level 1
API response structure
What is the best practice if I have an API that returns an array for user status and every key of this response has it is logic it does not come from one model but multiple models with business logic? while the resource class accepts only one model. should I implement a custom class, for example, UserStatsResponse this class has a method return array for the structure that I need.
Please or to participate in this conversation.