From f10a15a6e3d969398cd3f596973c934a540d4e12 Mon Sep 17 00:00:00 2001 From: jeremykenedy Date: Sun, 16 Jul 2017 22:29:22 -0700 Subject: [PATCH] add enable/disable option for updater in configs --- src/Config/installer.php | 13 ++++++++++++- src/Middleware/canUpdate.php | 26 ++++++++++++++++++-------- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/src/Config/installer.php b/src/Config/installer.php index 39988a1..be1fda7 100755 --- a/src/Config/installer.php +++ b/src/Config/installer.php @@ -121,11 +121,22 @@ | Selected Installed Middlware Option |-------------------------------------------------------------------------- | The selected option fo what happens when an installer intance has been - | Default output is to `/resources/views/error/404.blade.php` + | Default output is to `/resources/views/error/404.blade.php` if none. | The available middleware options include: | route, abort, dump, 404, default, '' | */ 'installedAlreadyAction' => '', + /* + |-------------------------------------------------------------------------- + | Updater Enabled + |-------------------------------------------------------------------------- + | Can the application run the '/update' route with the migrations. + | The default option is set to False if none is present. + | Boolean value + | + */ + 'updaterEnabled' => 'true', + ]; diff --git a/src/Middleware/canUpdate.php b/src/Middleware/canUpdate.php index 8bb7aef..1b8fe40 100755 --- a/src/Middleware/canUpdate.php +++ b/src/Middleware/canUpdate.php @@ -18,16 +18,26 @@ class canUpdate */ public function handle($request, Closure $next) { - $canInstall = new canInstall; + $updateEnabled = filter_var(config('installer.updaterEnabled'), FILTER_VALIDATE_BOOLEAN); + switch ($updateEnabled) { + case true: + $canInstall = new canInstall; - // if the application has not been installed, - // redirect to the installer - if (!$canInstall->alreadyInstalled()) { - return redirect()->route('LaravelInstaller::welcome'); - } + // if the application has not been installed, + // redirect to the installer + if (!$canInstall->alreadyInstalled()) { + return redirect()->route('LaravelInstaller::welcome'); + } + + if($this->alreadyUpdated()) { + abort(404); + } + break; - if($this->alreadyUpdated()) { - abort(404); + case false: + default: + abort(404); + break; } return $next($request);