@@ -49,7 +49,7 @@ public function __construct($app)
4949 * Get a database connection instance.
5050 *
5151 * @param string $name
52- * @return \Illuminate\Database\ Connection
52+ * @return Connection
5353 */
5454 public function connection ($ name = null )
5555 {
@@ -72,7 +72,7 @@ public function connection($name = null)
7272 * Reconnect to the given database.
7373 *
7474 * @param string $name
75- * @return \Illuminate\Database\ Connection
75+ * @return Connection
7676 */
7777 public function reconnect ($ name = null )
7878 {
@@ -85,7 +85,7 @@ public function reconnect($name = null)
8585 * Make the database connection instance.
8686 *
8787 * @param string $name
88- * @return \Illuminate\Database\ Connection
88+ * @return Connection
8989 */
9090 protected function makeConnection ($ name )
9191 {
@@ -102,18 +102,26 @@ protected function makeConnection($name)
102102 /**
103103 * Prepare the database connection instance.
104104 *
105- * @param \Illuminate\Database\ Connection $connection
106- * @return \Illuminate\Database\ Connection
105+ * @param Connection $connection
106+ * @return Connection
107107 */
108108 protected function prepare (Connection $ connection )
109109 {
110110 $ connection ->setEventDispatcher ($ this ->app ['events ' ]);
111111
112+ // The database connection can also utilize a cache manager instance when cache
113+ // functionality is used on queries, which provides an expressive interface
114+ // to caching both fluent queries and Eloquent queries that are executed.
115+ $ app = $ this ->app ;
116+
117+ $ connection ->setCacheManager (function () use ($ app )
118+ {
119+ return $ app ['cache ' ];
120+ });
121+
112122 // We will setup a Closure to resolve the paginator instance on the connection
113123 // since the Paginator isn't sued on every request and needs quite a few of
114124 // our dependencies. It'll be more efficient to lazily resolve instances.
115- $ app = $ this ->app ;
116-
117125 $ connection ->setPaginator (function () use ($ app )
118126 {
119127 return $ app ['paginator ' ];
@@ -167,25 +175,15 @@ public function setDefaultConnection($name)
167175 }
168176
169177 /**
170- * Return a new QueryBuilder for a collection
171- *
172- * @param string $collection
173- * @return QueryBuilder
174- */
175- public function collection ($ collection )
176- {
177- return new QueryBuilder ($ this ->connection (), $ collection );
178- }
179-
180- /**
181- * Return a new QueryBuilder for a collection
178+ * Dynamically pass methods to the default connection.
182179 *
183- * @param string $collection
184- * @return QueryBuilder
180+ * @param string $method
181+ * @param array $parameters
182+ * @return mixed
185183 */
186- public function __get ( $ collection )
184+ public function __call ( $ method , $ parameters )
187185 {
188- return $ this ->collection ( $ collection );
186+ return call_user_func_array ( array ( $ this ->connection (), $ method ), $ parameters );
189187 }
190188
191189}
0 commit comments