Cachet is now a Laravel 5 app
This commit is contained in:
36
app/Http/Middleware/AppIsSetup.php
Normal file
36
app/Http/Middleware/AppIsSetup.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Middleware;
|
||||
|
||||
use CachetHQ\Cachet\Models\Setting;
|
||||
use Closure;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
|
||||
class AppIsSetup
|
||||
{
|
||||
/**
|
||||
* 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
|
||||
* @param \Closure $next
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
try {
|
||||
$setting = Setting::where('name', 'app_name')->first();
|
||||
if ($setting && $setting->value) {
|
||||
return Redirect::route('dashboard');
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user