File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -246,19 +246,21 @@ public function reconnect($name = null)
246
246
}
247
247
248
248
/**
249
- * Set the database connection for the callback execution.
249
+ * Set the default database connection for the callback execution.
250
250
*
251
251
* @param string $name
252
252
* @param callable $callback
253
- * @return void
253
+ * @return mixed
254
254
*/
255
255
public function usingConnection (string $ name , callable $ callback )
256
256
{
257
257
$ previousName = $ this ->getDefaultConnection ();
258
258
259
259
$ this ->setDefaultConnection ($ name );
260
- $ callback ();
261
- $ this ->setDefaultConnection ($ previousName );
260
+
261
+ return tap ($ callback (), function () use ($ previousName ) {
262
+ $ this ->setDefaultConnection ($ previousName );
263
+ });
262
264
}
263
265
264
266
/**
You can’t perform that action at this time.
0 commit comments