2014-11-23 21:34:31 +00:00
|
|
|
<?php
|
|
|
|
|
2015-03-20 18:30:45 -06:00
|
|
|
namespace CachetHQ\Cachet\Http\Middleware;
|
2015-01-02 00:18:19 +00:00
|
|
|
|
|
|
|
use CachetHQ\Cachet\Models\Setting;
|
2015-03-20 18:30:45 -06:00
|
|
|
use Closure;
|
2015-01-02 00:18:19 +00:00
|
|
|
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
|
|
|
{
|
2014-11-27 16:05:00 +00:00
|
|
|
try {
|
2014-12-20 18:17:33 +00:00
|
|
|
$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');
|
2014-11-27 16:05:00 +00:00
|
|
|
}
|
|
|
|
} catch (Exception $e) {
|
2014-12-28 16:07:18 +00:00
|
|
|
// do nothing
|
2014-11-27 16:05:00 +00:00
|
|
|
}
|
2015-03-20 18:30:45 -06:00
|
|
|
|
|
|
|
return $next($request);
|
2014-11-27 16:05:00 +00:00
|
|
|
}
|
2014-11-27 22:08:28 +00:00
|
|
|
}
|