| Total Complexity | 5 |
| Total Lines | 45 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php namespace GeneaLabs\LaravelModelCaching; |
||
| 12 | abstract class CachedModel extends Model |
||
| 13 | { |
||
| 14 | public function newEloquentBuilder($query) |
||
| 15 | { |
||
| 16 | return new Builder($query); |
||
| 17 | } |
||
| 18 | |||
| 19 | public static function boot() |
||
| 20 | { |
||
| 21 | parent::boot(); |
||
| 22 | $class = get_called_class(); |
||
| 23 | $instance = new $class; |
||
| 24 | |||
| 25 | static::created(function () use ($instance) { |
||
| 26 | $instance->flushCache(); |
||
| 27 | }); |
||
| 28 | |||
| 29 | static::deleted(function () use ($instance) { |
||
| 30 | $instance->flushCache(); |
||
| 31 | }); |
||
| 32 | |||
| 33 | static::saved(function () use ($instance) { |
||
| 34 | $instance->flushCache(); |
||
| 35 | }); |
||
| 36 | |||
| 37 | static::updated(function () use ($instance) { |
||
| 38 | $instance->flushCache(); |
||
| 39 | }); |
||
| 40 | } |
||
| 41 | |||
| 42 | public function cache(array $tags = []) |
||
| 52 | } |
||
| 53 | |||
| 54 | public function flushCache(array $tags = []) |
||
| 57 | } |
||
| 58 | } |
||
| 59 |