Skip to content
This repository has been archived by the owner on Nov 28, 2023. It is now read-only.

Commit

Permalink
add enable/disable option for updater in configs
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremykenedy committed Jul 17, 2017
1 parent dd214e0 commit f10a15a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 9 deletions.
13 changes: 12 additions & 1 deletion src/Config/installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',

];
26 changes: 18 additions & 8 deletions src/Middleware/canUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit f10a15a

Please sign in to comment.