Replies: 3 comments 1 reply
-
Implementing #14 would solve this problem, because I could transform the Role ID to the expected representation before it is validated. |
Beta Was this translation helpful? Give feedback.
-
Correct me if I'm wrong, but in this case I would only use the role_id in the data object without the object and name field. Then to the frontend I would send the data object + an array with a mapping from role id to role name. This removes a lot of data duplication. |
Beta Was this translation helpful? Give feedback.
-
Let's say, for example, that in Vue, given this
If I'm right, you are suggesting to send only
But... what if the
We obviously can't write this:
Which is, according to you @rubenvanassche, the correct way to handle a generic remote field Thanks if you may help 🙏 |
Beta Was this translation helpful? Give feedback.
-
Let's assume I have the following strucutre:
UserController.php:
Usually I would create a form in Vue like this:
Now the problem is the following: The
UserData
expects$role
to be aRoleData
withid
andname
, but the frontend only sends the ID of the it. Should I usefromRequest()
to retrieve the Role from the database first? Or should I add a cast that does that.Normally the validation rules would look this:
StoreUserRequest.php
How does this translate to
laravel-data
? Hope I'm clear enough. 😅Beta Was this translation helpful? Give feedback.
All reactions