Skip to content

Commit

Permalink
only use dynamic tenant database in production environment
Browse files Browse the repository at this point in the history
  • Loading branch information
martiendt committed Jun 13, 2018
1 parent e89fc76 commit 29e5e34
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions app/Http/Middleware/TenantMiddleware.php
Expand Up @@ -16,9 +16,11 @@ class TenantMiddleware
*/
public function handle($request, Closure $next)
{
if ($request->header('Tenant')) {
config()->set('database.connections.tenant.database', 'point_'.$request->header('Tenant'));
DB::connection('tenant')->reconnect();
if (env('APP_ENV') === 'production') {
if ($request->header('Tenant')) {
config()->set('database.connections.tenant.database', 'point_'.$request->header('Tenant'));
DB::connection('tenant')->reconnect();
}
}

return $next($request);
Expand Down

0 comments on commit 29e5e34

Please sign in to comment.