rdx / laravel-remember-getters
Remember Model getters instead of getting every time
1.0
2018-12-30 12:15 UTC
This package is auto-updated.
Last update: 2024-10-29 05:10:58 UTC
README
class User extends Model {
use RemembersAttributes;
function getCheapAttribute() {
// This is executed for every $user->cheap access
return 13;
}
function rememberExpensiveAttribute() {
// This is executed only once per $user, no matter how many $user->expensive accesses
return $this->instances()->join(...)->distinct()->get();
}
}