jrumbut / eloquent-memoize
Memoization for Eloquent (Laravel) Models
Installs: 7 432
Dependents: 0
Suggesters: 0
Security: 0
Stars: 8
Watchers: 3
Forks: 4
Open Issues: 0
Requires
- php: >=5.5.0
- illuminate/database: 5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*
- illuminate/support: 5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*
Requires (Dev)
- phpmd/phpmd: ~2.3
- phpunit/phpunit: ~4.8 || ~5.0
- squizlabs/php_codesniffer: ~2.3
This package is not auto-updated.
Last update: 2024-11-23 20:09:56 UTC
README
Memoization for Eloquent models.
Install
Via Composer
$ composer require jrumbut/eloquent-memoize
Usage
class MyModel extends MemoizingModel { protected static $memoized = ['slow_attribute']; //Now only slow the first time it's accessed public function getSlowAttribute($value) { sleep(3); return ucwords($value); } }
-or-
class TraitModel extends Model { use Memoizes; /** * Initialize attributes * * @return void */ public static function boot() { parent::boot(); static::setMemoized(['slow']); } //Now only slow the first time it's accessed public function getSlowAttribute($value) { sleep(3); return ucwords($value); } }
Change log
Please see CHANGELOG for more information what has changed recently.
Testing
$ composer test
Contributing
Please see CONTRIBUTING and CONDUCT for details.
Security
If you discover any security related issues, please email joshua.rumbut@gmail.com instead of using the issue tracker.
Credits
- Joshua Rumbut
- Akihito Koriyama (akihito.koriyama@gmail.com) for the excellent PHP.Skeleton package
- All Contributors
License
The MIT License (MIT). Please see License File for more information.