Make LocationModel compatible with $guarded fields#53
Make LocationModel compatible with $guarded fields#53LukeTowers merged 2 commits intorainlab:masterfrom
Conversation
Closes rainlab#52. Checks if the implementing model has defined `$fillable` properties before adding location properties as fillable. This allows the developer to choose either the whitelist approach (eg. defining `$fillable` fields), or the blacklist approach (eg. defining `$guarded` fields) for mass-assignment protection.
|
Shouldn't this check the guarded properties instead? A model could define neither but disallow mass assignment until one of them is defined, in which case we need the behavior to add those fillable properties. |
|
Ah, you're right. I didn't realize that the default behavior is to guard everything. It looks like the So you are right, if the developer does not define either |
If `$guarded` has not been overridden by the implementing model, then location-specific fillable fields must be added.
|
Doesn't this cause an issue if the developer has overridden the guarded property to manually blacklist guarded properties? |
|
I hope not, since that's the very issue this PR is attempting to solve! 😉Are you seeing something different in your testing? In my testing, this patch works as expected in all of the following cases:
The only case that is not supported is if the developer overrides both
|
|
Hey @LukeTowers, I understand you're busy -- I just wanted to make sure that you're not still waiting on something from me. If any other changes are needed before this can be merged in, please let me know. Thanks! |
|
@voveson thanks for the reminder :) |
Closes #52.
Checks if the implementing model has defined
$fillableproperties before adding location properties as fillable. This allows the developer to choose either the whitelist approach (eg. defining$fillablefields), or the blacklist approach (eg. defining$guardedfields) for mass-assignment protection.