/** * Generate the unique cache key for the query. * * @return string */ public function generateCacheKey() { $name = $this->connection->getName(); return md5($name . $this->toSql() . serialize($this->getBindings())); }
/** * Prepare the database connection instance. * * @param \Database\Connection $connection * @return \Database\Connection */ protected function prepare(Connection $connection) { $connection->setFetchMode($this->app['config']['database.fetch']); if ($this->app->bound('events')) { $connection->setEventDispatcher($this->app['events']); } $app = $this->app; $connection->setCacheManager(function () use($app) { return $app['cache']; }); $connection->setPaginator(function () use($app) { return $app['paginator']; }); $connection->setReconnector(function ($connection) { $this->reconnect($connection->getName()); }); return $connection; }