Ability to disable wrapping on a Resource per resource #45648
Replies: 2 comments 2 replies
-
Are you talking about https://laravel.com/docs/9.x/eloquent-resources#data-wrapping? It can already turned off per resource, although your description explains as if you want it to be turned off globally. |
Beta Was this translation helpful? Give feedback.
-
This problem just forced painfully me to refresh my knowledge about phpunit and how static variables are used during tests. What happened to me was that I was calling I would consider this a design flaw to have the Another example where this problem would lead to conflicts is, if an installed package also uses the default wrap property of the base class. For others who might encounter a similar problem, there are as far as I know only two things you can do right now to work around the problem:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm using Inertia + Resources to load data into a Vue component like this:
Due to the wrapping, in my Vue component profile data is accessible via
props.profile.data
. To workaround this I've created a Resource which all of my resources extend from (like we do with the controllers).If there's any interest in having this functionality in the main codebase let me know and I'll get a pull request created. I'm also thinking about creating a HasResource trait (similar to the HasFactory trait) which will allow me to do:
To quickly wrap the profile in the correct resource using the model name and namespace. Let me know if there's any interest in either of these ideas 😄
Beta Was this translation helpful? Give feedback.
All reactions