mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-26 06:04:08 -08:00
1a14abed05
Should probably find a way to handle this that doesn't require a DB call
43 lines
851 B
PHP
43 lines
851 B
PHP
<?php
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
use Closure;
|
|
use Config;
|
|
use Route;
|
|
use Schema;
|
|
use App\Models\User;
|
|
|
|
class CheckForSetup
|
|
{
|
|
public function handle($request, Closure $next, $guard = null)
|
|
{
|
|
|
|
try {
|
|
|
|
$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);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|