From 1a14abed05fb91fd1efdc6ccbede53ecc5f4ae1a Mon Sep 17 00:00:00 2001 From: snipe Date: Sat, 14 May 2016 15:05:20 -0700 Subject: [PATCH] Check that the table exists Should probably find a way to handle this that doesn't require a DB call --- app/Http/Middleware/CheckForSetup.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/app/Http/Middleware/CheckForSetup.php b/app/Http/Middleware/CheckForSetup.php index f0db94ddf7..03319cd110 100644 --- a/app/Http/Middleware/CheckForSetup.php +++ b/app/Http/Middleware/CheckForSetup.php @@ -5,6 +5,7 @@ namespace App\Http\Middleware; use Closure; use Config; use Route; +use Schema; use App\Models\User; class CheckForSetup @@ -13,12 +14,22 @@ class CheckForSetup { try { - $usercount = User::withTrashed()->count(); - if (($usercount > 0) && (Route::is('setup*'))) { - return redirect(config('app.url')); + + $users_table_exists = Schema::hasTable('users'); + $settings_table_exists = Schema::hasTable('settings'); + + if ($users_table_exists && $settings_table_exists) { + $usercount = User::withTrashed()->count(); + if (($usercount > 0) && (Route::is('setup*'))) { + return redirect(config('app.url')); + } else { + return $next($request); + } } else { return $next($request); } + + } catch (\Exception $e) { return $next($request); }