Cachet/app/Http/Middleware/AppIsSetup.php

37 lines
864 B
PHP
Raw Normal View History

2014-11-23 21:34:31 +00:00
<?php
2015-03-20 18:30:45 -06:00
namespace CachetHQ\Cachet\Http\Middleware;
use CachetHQ\Cachet\Models\Setting;
2015-03-20 18:30:45 -06:00
use Closure;
use Exception;
use Illuminate\Support\Facades\Redirect;
2015-03-20 18:30:45 -06:00
class AppIsSetup
2014-12-20 21:20:17 +00:00
{
2015-01-02 00:54:16 +00:00
/**
* Run the is setup filter.
*
* We're verifying that Cachet is correctly setup. If it is, they we're
* sending the user to the dashboard so they can use Cachet.
*
* @param \Illuminate\Routing\Route $route
2015-03-20 18:30:45 -06:00
* @param \Closure $next
2015-01-02 00:54:16 +00:00
*
2015-03-20 18:30:45 -06:00
* @return mixed
2015-01-02 00:54:16 +00:00
*/
2015-03-20 18:30:45 -06:00
public function handle($request, Closure $next)
2014-12-20 21:20:17 +00:00
{
try {
$setting = Setting::where('name', 'app_name')->first();
2015-01-02 00:54:16 +00:00
if ($setting && $setting->value) {
2015-03-20 18:30:45 -06:00
return Redirect::route('dashboard');
}
} catch (Exception $e) {
2014-12-28 16:07:18 +00:00
// do nothing
}
2015-03-20 18:30:45 -06:00
return $next($request);
}
}