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

31 lines
534 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;
class CheckForSetup
{
public function handle($request, Closure $next, $guard = null)
{
try {
$usercount = \App\Models\User::withTrashed()->count();
if (($usercount > 0) && (Route::is('setup*'))) {
return redirect(config('app.url'));
} else {
return $next($request);
}
} catch (\Exception $e) {
return $next($request);
}
}
}