Skip to content

htaketani/laravel-computed-once-attributes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

laravel-computed-once-attributes

Simple caching attributes of computed by accessor method

Installation

Download HasComputedOnceAttributes.php, and move file into your project dir (e.g. app/Traits/).

Usage

use App\Traits\HasComputedOnceAttributes;

class MyModel extends Model
{
    use HasComputedOnceAttributes;

    // Declare only-once-computed attribute keys
    protected $computed_once_attributes = ['foo'];

    public function getFooAttribute()
    {
        return (... SOME HEAVY PROCCESS ...);
    }
}

Thanks

yuuAn, thanks for your advices.

About

Simple caching attributes of computed by accessor method for Laravel Eloquent

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages