Replies: 2 comments
-
None of both of the cases, since we only create data from request values. Since none are provided the injection isn't working. You could try using the route parameter injection but the solution you're using now is in my opinion the way to go. |
Beta Was this translation helpful? Give feedback.
-
If you are running into the issue where it fails validation but doesn't return the normal validation response. In the global error handler
Unsure if this is the exact issue you were running into that made you question this, but for my API only instance of laravel it solved my problem. |
Beta Was this translation helpful? Give feedback.
-
Hello,
I have a question about how Data objects get created when referenced in a route parameter.
Based on this very simple code:
When someone visits
http://localhost/admin/getUser/1
should I expect that:$user
data object gets created from loaded User model$user
gets validated$user
data objectOR
$user
$user
validates but validation fails because the required filedemail
is missing (only the id is passed in the route parameter)$user
never gets createdRight now, it looks like the first scenario (where I get a valid
$user
data object in my Controller) is only possible if I change the signature of the controller function topublic function getUser(User $user) {...}
and then manually get the$userData
data object from inside the function using something likeUserData::from($user)
.Thanks for your insight.
Beta Was this translation helpful? Give feedback.
All reactions