snipe-it/app/Http/Middleware/CheckForSetup.php

32 lines
543 B
PHP
Raw Normal View History

2016-03-25 01:18:05 -07:00
<?php
namespace App\Http\Middleware;
use Closure;
use Config;
use Route;
2016-03-25 19:26:22 -07:00
use App\Models\User;
2016-03-25 01:18:05 -07:00
class CheckForSetup
{
public function handle($request, Closure $next, $guard = null)
{
try {
2016-03-25 19:26:22 -07:00
$usercount = User::withTrashed()->count();
2016-03-25 01:18:05 -07:00
if (($usercount > 0) && (Route::is('setup*'))) {
return redirect(config('app.url'));
} else {
return $next($request);
}
} catch (\Exception $e) {
return $next($request);
}
}
}