Replies: 4 comments 6 replies
-
I was assuming I can use the public static function fromRequest(Request $request): static
{
return static::from(array_merge($request->all(), ['id' => $request->route()?->parameter('song')->id]));
} Unfortunately, it looks like validation runs before the |
Beta Was this translation helpful? Give feedback.
-
The reason why the pipeline runs before the custom creation method is because at that point you want to make sure the data you're receiving from the frontend is completely validated. The reason for the alternative pipeline was for performance reasons but I don't think that actually will be a huge issue so I've removed it. What I would do:
At the moment I don't have the time to build such a thing 😄. I had the plan to completely rewrite the validation engine for data v3 but that's not something I can start working on in the next months. So you're always welcome to PR such a thing! |
Beta Was this translation helpful? Give feedback.
-
Sorry if I say so, but this currently makes |
Beta Was this translation helpful? Give feedback.
-
here how I do a quick hack to override the rule in controller
|
Beta Was this translation helpful? Give feedback.
-
I have a use-case where I need to add a
Unique
validation rule to a data object, which should ignore the current object's ID. Very much like described here - "Forcing A Unique Rule To Ignore A Given ID".This data object is typehinted in the controller, so it's used instead of a
FormRequest
class. The frontend does not provide the ID in the payload - it's only available in the route params.My question is twofold:
SongData
class somehow automatically map the ID from route params to the SongData::$id property?Route & controller
SongData.php
Beta Was this translation helpful? Give feedback.
All reactions