louiss0's avatar

louiss0 wrote a comment+100 XP

4mos ago

You should find a way not to use namespace. As an industry we are moving away from TS only features.

louiss0's avatar

louiss0 liked a comment+100 XP

4mos ago

There are many ways to go about this.

  1. Keep it in the controller
  2. Move the fetch to the model
  3. Create a service class that you and move the fetch there
  4. Use some fancy pattern to achieve the result

Which ever you choose, don't make it more complex than you need to. The logic is quite easy to refactor if and when you need to.

Be aware that your API (When you move there) probably should use a JSON Resource

https://laravel.com/docs/12.x/eloquent-resources

louiss0's avatar

louiss0 wrote a comment+100 XP

4mos ago

@lukedowning19 Did you ever find a new solution to this?

louiss0's avatar

louiss0 wrote a comment+100 XP

5mos ago

@schopin I wish there was a way for it not to matter!