mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 13:44:06 -08:00
Check that the table exists
Should probably find a way to handle this that doesn't require a DB call
This commit is contained in:
parent
4dd3a95b6d
commit
1a14abed05
|
@ -5,6 +5,7 @@ namespace App\Http\Middleware;
|
||||||
use Closure;
|
use Closure;
|
||||||
use Config;
|
use Config;
|
||||||
use Route;
|
use Route;
|
||||||
|
use Schema;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
|
||||||
class CheckForSetup
|
class CheckForSetup
|
||||||
|
@ -13,12 +14,22 @@ class CheckForSetup
|
||||||
{
|
{
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$usercount = User::withTrashed()->count();
|
|
||||||
if (($usercount > 0) && (Route::is('setup*'))) {
|
$users_table_exists = Schema::hasTable('users');
|
||||||
return redirect(config('app.url'));
|
$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 {
|
} else {
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue