Cachet is now a Laravel 5 app

This commit is contained in:
Joseph Cohen
2015-03-20 18:30:45 -06:00
parent 7cfa158e68
commit b4ac66d727
338 changed files with 4164 additions and 4114 deletions

View File

@@ -0,0 +1,53 @@
<?php
namespace CachetHQ\Cachet\Http\Middleware;
use CachetHQ\Cachet\Models\Setting;
use Closure;
use Exception;
use Illuminate\Support\Facades\Redirect;
class HasSetting
{
/**
* Run the has setting middleware.
*
* We're verifying that the given setting exists in our database. If it
* doesn't, then we're sending the user to the setup page so that they can
* complete the installation of Cachet on their server.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
*
* @return mixed
*/
public function handle($request, Closure $next)
{
$settingName = $this->getSettingName($request);
try {
$setting = Setting::where('name', $settingName)->first();
if (!$setting || !$setting->value) {
return Redirect::to('setup');
}
} catch (Exception $e) {
return Redirect::to('setup');
}
return $next($request);
}
/**
* Get the setting from the request.
*
* @param \Illuminate\Http\Request $request
*
* @return array
*/
private function getSettingName($request)
{
$actions = $request->route()->getAction();
return $actions['setting'];
}
}