PHPackages                             bennett-treptow/laravel-cached-mutators - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. bennett-treptow/laravel-cached-mutators

ActiveLibrary[Caching](/categories/caching)

bennett-treptow/laravel-cached-mutators
=======================================

Cached model mutators

v1.2.0(6y ago)44.0k↓88.9%1[3 issues](https://github.com/bennett-treptow/laravel-cached-mutators/issues)[3 PRs](https://github.com/bennett-treptow/laravel-cached-mutators/pulls)MITPHPPHP ^7.0

Since Jan 13Pushed 3y ago1 watchersCompare

[ Source](https://github.com/bennett-treptow/laravel-cached-mutators)[ Packagist](https://packagist.org/packages/bennett-treptow/laravel-cached-mutators)[ Docs](https://github.com/bennett-treptow/laravel-cached-mutators)[ RSS](/packages/bennett-treptow-laravel-cached-mutators/feed)WikiDiscussions master Synced yesterday

READMEChangelog (5)Dependencies (2)Versions (9)Used By (0)

Laravel Cached Mutators [![Actions Status](https://github.com/bennett-treptow/laravel-cached-mutators/workflows/Laravel/badge.svg)](https://github.com/bennett-treptow/laravel-cached-mutators/actions)
=======================================================================================================================================================================================================

[](#laravel-cached-mutators-)

This package provides a trait for your Eloquent models to automatically cache any mutators and attributes you choose. Good use cases for this trait are for expensive mutators that you only want to run once per request / certain time period and want to keep your mutator code free from any manual caching.

This package works by hooking into the Eloquent model's `getAttributeValue` function, and passing thru the value if the specified attribute does not need to be cached as per the `$cacheAttributes`.

Install
-------

[](#install)

`composer require bennett-treptow/laravel-cached-mutators`

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

```
