-
Notifications
You must be signed in to change notification settings - Fork 11k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[6.x] Allow formatting an implicit attribute using a closure #31246
Conversation
* @return $this | ||
*/ | ||
public function setImplicitAttributesFormatter(callable $formatter) | ||
public function setImplicitAttributesFormatter($formatter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can keep the typehint (callable $formatter = null)
Hi @themsaid , I'm just reading the 6.13 changelog. Can you help me to understand this new behavior with a real case usage? 😇 |
Hi @themsaid! Great feature it seems, I want to shoot a video about it, but I don't understand - is it possible to use it with |
@PovilasKorop You'll want to use:
@MarceauKa the example above is a real use case :) |
@themsaid thanks, it's working, tried it with a bit changed example, will shoot a video tomorrow.
|
I made it working like in Laravel 8.x public function withValidator(Validator $validator)
{
$validator->setImplicitAttributesFormatter(function ($attribute) {
return Str::of($attribute)->afterLast('.');
});
} This is a hidden gem. |
This PR adds a
setImplicitAttributesFormatter
method to the validator that allows the instance to output a message that says:instead of