Package Data | |
---|---|
Maintainer Username: | jrumbut |
Maintainer Contact: | joshua.rumbut@gmail.com (Joshua Rumbut) |
Package Create Date: | 2016-07-10 |
Package Last Update: | 2021-10-01 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-21 03:02:05 |
Package Statistics | |
---|---|
Total Downloads: | 7,432 |
Monthly Downloads: | 2 |
Daily Downloads: | 0 |
Total Stars: | 8 |
Total Watchers: | 3 |
Total Forks: | 4 |
Total Open Issues: | 0 |
Memoization for Eloquent models.
Via Composer
$ composer require jrumbut/eloquent-memoize
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);
}
}
Please see CHANGELOG for more information what has changed recently.
$ composer test
Please see CONTRIBUTING and CONDUCT for details.
If you discover any security related issues, please email joshua.rumbut@gmail.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.