2016-08-28 18:33:47 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Providers;
|
|
|
|
|
2016-11-18 16:46:58 +08:00
|
|
|
use Illuminate\Http\Request;
|
2018-06-30 16:31:39 +08:00
|
|
|
use Composer\Semver\Comparator;
|
2016-08-28 18:33:47 +08:00
|
|
|
use Illuminate\Support\ServiceProvider;
|
2016-12-18 17:32:46 +08:00
|
|
|
use App\Http\Controllers\SetupController;
|
2016-08-28 18:33:47 +08:00
|
|
|
|
2018-09-08 20:03:55 +08:00
|
|
|
class RuntimeCheckServiceProvider extends ServiceProvider
|
2016-08-28 18:33:47 +08:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Bootstrap any application services.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2016-11-18 16:46:58 +08:00
|
|
|
public function boot(Request $request)
|
2016-08-28 18:33:47 +08:00
|
|
|
{
|
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
|
|
|
|
*/
|
2016-08-28 18:33:47 +08:00
|
|
|
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()) {
|
2016-11-18 16:46:58 +08:00
|
|
|
return redirect('/setup')->send();
|
2016-08-28 18:33:47 +08:00
|
|
|
}
|
|
|
|
|
2018-06-30 16:31:39 +08:00
|
|
|
if (Comparator::greaterThan(config('app.version'), option('version'))) {
|
2016-11-18 16:46:58 +08:00
|
|
|
return redirect('/setup/update')->send();
|
2016-08-28 18:33:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Register any application services.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function register()
|
|
|
|
{
|
2018-07-22 16:37:39 +08:00
|
|
|
//
|
2016-08-28 18:33:47 +08:00
|
|
|
}
|
|
|
|
}
|