[13.x] Add 'image' cast to model - #60949
Conversation
|
Thanks for submitting a PR! Note that draft PRs are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface. Pull requests that are abandoned in draft may be closed due to inactivity. |
| case 'image:storage': | ||
| case 'image:base64': | ||
| case 'image:bytes': | ||
| return $this->toImage($value, substr($castType, 6)); |
There was a problem hiding this comment.
Should this use Str::afterLast($castType, ':') instead of substr(...)?
There was a problem hiding this comment.
Possible, but browner will probably crucify me if I do this 😂
so nothing gets truncated Co-authored-by: Jamie York <jamie@fusionspim.com> See laravel#60949 (comment)
| case 'image:storage': | ||
| case 'image:base64': | ||
| case 'image:bytes': | ||
| return $this->toImage($key, $value, substr($castType, 6)); |
There was a problem hiding this comment.
Doesn't this make image cast always failed? as there no match for empty string.
There was a problem hiding this comment.
It does. I was just trying to figure out how everything prefixed with image: would not accidentally interpreted as class cast—which it did without the additional case 'image'
Maybe, you have a better idea how to solve this
It may be helpful to directly work with the image stored in the database without the caller needing to know how it is stored as this can be left as an implementation detail to the model.