Skip to content

Commit 1d5fa82

Browse files
get instance from function
1 parent b49e122 commit 1d5fa82

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/CachedModel.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,19 @@ public static function boot()
3030
{
3131
parent::boot();
3232

33-
$class = get_called_class();
34-
$instance = new $class;
35-
36-
static::created(function () use ($instance) {
33+
static::created(function ($instance) {
3734
$instance->flushCache();
3835
});
3936

40-
static::deleted(function () use ($instance) {
37+
static::deleted(function ($instance) {
4138
$instance->flushCache();
4239
});
4340

44-
static::saved(function () use ($instance) {
41+
static::saved(function ($instance) {
4542
$instance->flushCache();
4643
});
4744

48-
static::updated(function () use ($instance) {
45+
static::updated(function ($instance) {
4946
$instance->flushCache();
5047
});
5148
}

0 commit comments

Comments
 (0)