[9.x] Adds handlers for silently discarded and missing attribute violations#44664
Conversation
|
@aarondfrancis, maybe this is going to be a good feature but did you see that a lots of changes are showing just due to changes of a single space. I think it was happened due to IDE configuration, so that this type of unnecessary changes are showing. Could you please recheck the changes again please?? |
|
Fixed. I kinda thought that would happen automatically, which is why I left it. Thanks @deKuddus. And thanks to @timacdonald for this incredible tip on how to fix this! |
| * @param callable|null $callback | ||
| * @return void | ||
| */ | ||
| public static function handleDiscardedAttributeViolationUsing(?callable $callback) |
There was a problem hiding this comment.
Hey
What scenario users might be required to call handleDiscardedAttributeViolationUsing(null); ?
Same for handleMissingAttributeViolationUsing(null) case.
There was a problem hiding this comment.
My first thought would be during tests, to either enable or disable it dynamically. Not sure if that was the intended use-case.
This PR adds the ability to register handlers for two of the strict mode violations: silently discarded and missing attributes.
This ability is currently available for only the lazy load violations, this PR basically replicates that behavior for the other 2/3rds of Eloquent's new strict mode.
I think this will make it easier to adopt strict mode, as people can enable strict mode in production, but instead of throwing violations, they can log them.