You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 16, 2021. It is now read-only.
I've just been using the casts feature to cast a text field to an array, very helpful.
However, when the text field is empty the default return value is null. At present the default behaviour is to return the result of json_decode. I would propose an extra check here for the result and return an empty array instead.
This would then avoid having to check if the attribute is an array prior to handling as such.
For example
if (in_array(1, $my_model->options) {
// ...
}
rather than
if (is_array($my_model->options) && in_array(1, $my_model->options) {
// ...
}
I'd be happy to put this change together as a pull request but wanted to see if anyone had any reasons why this shouldn't be the default behaviour?
bafoed, c-fitzmaurice, weotch, brouwersron, richartkeil and 6 more