Cachet/app/Http/Middleware/SetupAlreadyCompleted.php

63 lines
1.4 KiB
PHP
Raw Normal View History

2014-11-23 21:34:31 +00:00
<?php
/*
* This file is part of Cachet.
*
2015-07-06 17:37:01 +01:00
* (c) Alt Three Services Limited
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
2015-03-20 18:30:45 -06:00
namespace CachetHQ\Cachet\Http\Middleware;
2017-01-03 14:34:23 +00:00
use CachetHQ\Cachet\Settings\Repository;
2015-03-20 18:30:45 -06:00
use Closure;
2016-02-11 11:35:40 +00:00
use Illuminate\Http\Request;
/**
* This is the setup already completed middelware class.
*
* @author Graham Campbell <james@alt-three.com>
* @author James Brooks <james@alt-three.com>
* @author Joseph Cohen <joe@alt-three.com>
*/
2015-12-24 17:30:59 +00:00
class SetupAlreadyCompleted
2014-12-20 21:20:17 +00:00
{
/**
2017-01-03 14:34:23 +00:00
* The settings repository instance.
*
2017-01-03 14:34:23 +00:00
* @var \CachetHQ\Cachet\Settings\Repository
*/
2017-01-03 14:34:23 +00:00
protected $settings;
/**
* Creates a new setup already completed middleware instance.
*
2017-01-03 14:34:23 +00:00
* @param \CachetHQ\Cachet\Settings\Repository $settings
*
* @return void
*/
2017-01-03 14:34:23 +00:00
public function __construct(Repository $settings)
{
2017-01-03 14:34:23 +00:00
$this->settings = $settings;
}
2015-01-02 00:54:16 +00:00
/**
2015-12-24 17:30:59 +00:00
* Handle an incoming request.
2015-01-02 00:54:16 +00:00
*
2015-12-22 08:41:03 +00:00
* @param \Illuminate\Http\Request $request
* @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
*/
2016-02-11 11:35:40 +00:00
public function handle(Request $request, Closure $next)
2014-12-20 21:20:17 +00:00
{
2017-01-03 14:34:23 +00:00
if ($this->settings->get('app_name')) {
return cachet_redirect('dashboard');
}
2015-03-20 18:30:45 -06:00
return $next($request);
}
}