/** * @param RepositoryEventBase $event */ public function handle(RepositoryEventBase $event) { try { $cleanEnabled = config("repository.cache.clean.enabled", true); if ($cleanEnabled) { $this->repository = $event->getRepository(); $this->model = $event->getModel(); $this->action = $event->getAction(); if (config("repository.cache.clean.on.{$this->action}", true)) { $cacheKeys = CacheKeys::getKeys(get_class($this->repository)); if (is_array($cacheKeys)) { foreach ($cacheKeys as $key) { $this->cache->forget($key); } } } } } catch (\Exception $e) { Log::error($e->getMessage()); } }