blessing-skin-server/app/Providers/RuntimeCheckServiceProvider.php

54 lines
1.2 KiB
PHP
Raw Normal View History

<?php
namespace App\Providers;
use Illuminate\Http\Request;
use Composer\Semver\Comparator;
use Illuminate\Support\ServiceProvider;
use App\Http\Controllers\SetupController;
2018-09-08 20:03:55 +08:00
class RuntimeCheckServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot(Request $request)
{
2018-07-22 18:54:37 +08:00
// Skip the installation check when in setup or under CLI
if ($request->is('setup*') || $this->app->runningInConsole()) {
return;
2017-01-18 22:31:35 +08:00
}
2018-07-22 18:54:37 +08:00
$this->checkInstallation(); // @codeCoverageIgnore
2017-01-18 22:31:35 +08:00
}
2018-07-22 18:54:37 +08:00
/**
* @codeCoverageIgnore
*/
protected function checkInstallation()
{
2018-02-16 17:31:04 +08:00
// Redirect to setup wizard
2019-04-09 13:21:31 +08:00
if (config('database.default') == 'dummy' || ! SetupController::checkTablesExist()) {
return redirect('/setup')->send();
}
if (Comparator::greaterThan(config('app.version'), option('version'))) {
return redirect('/setup/update')->send();
}
return true;
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
2018-07-22 16:37:39 +08:00
//
}
}