Conditions | 3 |
Paths | 4 |
Total Lines | 17 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
13 | public function handle(Request $request, Closure $next, null|string $ref = null) |
||
14 | { |
||
15 | if (!$ref) { |
||
16 | $ref = session(config('dynamicdatabaseconfig.session_ref', '_db_ref')); |
||
17 | } |
||
18 | |||
19 | [$database, $configuration, $name] = $this->getDynamicDatabaseConfiguration($ref); |
||
20 | |||
21 | $request->merge([config('dynamicdatabaseconfig.connection_name', '_db_connection') => $name]); |
||
22 | |||
23 | if ($database) { |
||
24 | $newConfig = $this->setNewDynamicConfig($database, $configuration); |
||
25 | $this->addNewConfig($database, $name, $newConfig); |
||
26 | $this->createDatabase($database, $configuration['database']); |
||
27 | } |
||
28 | |||
29 | return $next($request); |
||
30 | } |
||
33 |