laravel / framework

The Laravel Framework.
https://laravel.com
MIT License
32.62k stars 11.03k forks source link

Unset eloquent model's cached cast attribute #53583

Closed adamthehutt closed 1 day ago

adamthehutt commented 2 days ago

When a cast attribute is cached (either because the accessor returns an object or because shouldCache() is used), there is no way from outside the model to invalidate the cache.

This pull request expands the existing offsetUnset() method to unset the cached value when calling $model->unset($attribute).