/** * Prepare the database connection instance. * * @param Illuminate\Database\Connection $connection * @return Illuminate\Database\Connection */ protected function prepare(Connection $connection) { $connection->setEventDispatcher($this->app['events']); // 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. $app = $this->app; $connection->setPaginator(function () use($app) { return $app['paginator']; }); return $connection; }
/** * Retrieve a user by the given credentials. * * @param array $credentials * @return Illuminate\Auth\UserInterface|null */ public function retrieveByCredentials(array $credentials) { $query = $this->connection->collection($this->collection); foreach ($credentials as $key => $value) { if (!str_contains($key, 'password')) { $query->where($key, $value); } } $user = $query->first(); if (!is_null($user)) { $user['id'] = (string) $user['_id']; return new GenericUser((array) $user); } }
/** * 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; }
/** * Retrieve a user by by their unique identifier and "remember me" token. * * @param mixed $identifier * @param string $token * @return \Illuminate\Auth\UserInterface|null */ public function retrieveByToken($identifier, $token) { $user = $this->connection->collection($this->collection)->find($identifier); return $token == $user->getRememberTokenName() ? $user : null; }
/** * Begin a new database query against the collection. * * @return LMongo\Query\Builder */ protected function getCollection() { return $this->connection->collection($this->collection); }