• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: Show Laravel resources API for only specific routes

Resolved: Show Laravel resources API for only specific routes

0
By Isaac Tonny on 17/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

Is it possible to show new added Laravel resources API fields on specific routes?
Example: I have a UserResource which has 3 fields – id, name and email. I’m returning UserResource in 10 routes. For 11th route added new field – posts.
Is it possible to show new posts field only for 11th route?

Answer:

Of course you can, so you need to add two things. First inside of your controller in the method where you want to load posts do the following
Then inside of your UserResourse class add the following

If you have better answer, please add a comment about this, thank you!

api laravel
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: PyCharm cannot see my newly compiled .pyc see on import

27/03/2023

Resolved: I am facing ERR_HTTP2_PROTOCOL_ERROR on my website

27/03/2023

Resolved: TypeScript does not recognize properties when instantiating interface array

27/03/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.