Skip to content

Package to memoize dynamic attributes using the Eloquent ORM

License

Notifications You must be signed in to change notification settings

jrumbut/eloquent-memoize

Folders and files

NameName
Last commit message
Last commit date

Latest commit

00aa4e2 · Oct 1, 2021

History

43 Commits
Jul 17, 2016
Feb 7, 2017
Jul 10, 2016
Jul 12, 2016
Jul 8, 2016
Jul 8, 2016
Jul 10, 2016
Aug 28, 2018
Jul 17, 2016
Jul 10, 2016
Jul 10, 2016
Jul 8, 2016
Sep 26, 2017
Oct 2, 2020
Jul 8, 2016
Jul 10, 2016
Jul 10, 2016

Repository files navigation

EloquentMemoize

Latest Version on Packagist Software License Coverage Status Quality Score Total Downloads SensioLabsInsight

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 [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

About

Package to memoize dynamic attributes using the Eloquent ORM

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages