Skip to content

Commit db51a86

Browse files
move boot method into trait
1 parent 7533fbe commit db51a86

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

src/CachedModel.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,6 @@ public function newEloquentBuilder($query)
2626
return new Builder($query);
2727
}
2828

29-
public static function boot()
30-
{
31-
parent::boot();
32-
33-
static::saved(function ($instance) {
34-
$instance->flushCache();
35-
});
36-
}
37-
3829
public static function all($columns = ['*'])
3930
{
4031
$class = get_called_class();

src/Traits/Cachable.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,11 @@ protected function makeCacheTags() : array
6060
return (new CacheTags($this->eagerLoad, $this->model))
6161
->make();
6262
}
63+
64+
public static function bootCachable()
65+
{
66+
static::saved(function ($instance) {
67+
$instance->flushCache();
68+
});
69+
}
6370
}

0 commit comments

Comments
 (0)