You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm encountering an issue with the $request->safe() method while following the example described in the Spatie Laravel Data documentation.
Problem
When I make a request, the $request->safe() method returns an empty result, which suggests that the request is not being validated. I'm trying to understand how I can retrieve the validated data to save it to the database.
Current Approach
Currently, I use a data class to map data from the database to the response of a method. Additionally, I want to:
Update the model with the same data class.
Validate the data during this process.
Questions
How can I ensure that the data is validated and retrieve the validated data using $request->safe()?
Is there a different or better approach to achieve my goal of mapping, validating, and updating the model using the data class? How can I handle the situation where a field in the database has a different name than what is expected in the API's input and output?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm encountering an issue with the $request->safe() method while following the example described in the Spatie Laravel Data documentation.
Problem
When I make a request, the $request->safe() method returns an empty result, which suggests that the request is not being validated. I'm trying to understand how I can retrieve the validated data to save it to the database.
Current Approach
Currently, I use a data class to map data from the database to the response of a method. Additionally, I want to:
Questions
Thank you for your assistance!
Beta Was this translation helpful? Give feedback.
All reactions