#Laravel 11 Api Resource Class Problem

22 messages · Page 1 of 1 (latest)

wheat nest
#

So, I was trying to re-structure a collection from a model inside Api resource:

but it seems the api resource class is not working for some reason, it still returns the original structure of the User model, I even added dd() inside the resource class and it's not being triggered.

I'm new to 11 version, is there a problem with my implementation? please help.

sour goblet
#

I could't reproduce the error, when i return the user I get the json only with the id

wheat nest
#

what!

#

i even reinstalled new laravel app, im getting the same result 😦

sour goblet
#

Could you share a photo of the response that you are getting?

wheat nest
#

can you please dd() the $user?

#

if still get only id 😦

sour goblet
wheat nest
wheat nest
sour goblet
wheat nest
#

i cant really test the json response, im not using it as api

sour goblet
#

what are you using for the frontend?

wheat nest
#

vue with inertia ha

#

js*

#

ohh i actually get only the id if i return it on json

#

i just want to transform the user model before passing on vue component as props

#

Thank you @sour goblet i just found out

#

it actually convert the colection when i catch in on vue, but when i dd() it in controller, it shows the original

sour goblet