/**
* Prepare the database connection instance.
*
* @param \LMongo\Connection $connection
* @return \LMongo\Connection
*/
protected function prepare(Connection $connection)
{
if ($this->app->bound('events')) {
$connection->setEventDispatcher($this->app['events']);
}
// The database connection can also utilize a cache manager instance when cache
// functionality is used on queries, which provides an expressive interface
// to caching both fluent queries and Eloquent queries that are executed.
$app = $this->app;
$connection->setCacheManager(function () use($app) {
return $app['cache'];
});
// We will setup a Closure to resolve the paginator instance on the connection
// since the Paginator isn't sued on every request and needs quite a few of
// our dependencies. It'll be more efficient to lazily resolve instances.
$connection->setPaginator(function () use($app) {
return $app['paginator'];
});
return $connection;
}