From 739440015b55c43b3e6612039dd3b061e25e479d Mon Sep 17 00:00:00 2001 From: jeremykenedy Date: Sun, 16 Jul 2017 22:10:05 -0700 Subject: [PATCH 1/3] add already installed options --- src/Config/installer.php | 36 +++++++++++++++++++++++++++++++++++ src/Middleware/canInstall.php | 33 ++++++++++++++++++++++++++++---- 2 files changed, 65 insertions(+), 4 deletions(-) diff --git a/src/Config/installer.php b/src/Config/installer.php index 2454e56..39988a1 100755 --- a/src/Config/installer.php +++ b/src/Config/installer.php @@ -92,4 +92,40 @@ ], ], ], + + /* + |-------------------------------------------------------------------------- + | Installed Middlware Options + |-------------------------------------------------------------------------- + | Different available status switch configuration for the + | canInstall middleware located in `canInstall.php`. + | + */ + 'installed' => [ + 'redirectOptions' => [ + 'route' => [ + 'name' => 'welcome', + 'data' => [], + ], + 'abort' => [ + 'type' => '404', + ], + 'dump' => [ + 'data' => 'Dumping a not found message.', + ] + ], + ], + + /* + |-------------------------------------------------------------------------- + | 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` + | The available middleware options include: + | route, abort, dump, 404, default, '' + | + */ + 'installedAlreadyAction' => '', + ]; diff --git a/src/Middleware/canInstall.php b/src/Middleware/canInstall.php index 30b5f4e..9445b3b 100755 --- a/src/Middleware/canInstall.php +++ b/src/Middleware/canInstall.php @@ -4,6 +4,7 @@ use Closure; use DB; +use Redirect; class canInstall { @@ -13,15 +14,39 @@ class canInstall * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed + * @param Redirector $redirect + * @return \Illuminate\Http\RedirectResponse */ public function handle($request, Closure $next) { - - // Possible Feature: Make this some configurable option for easier customization and controversial desire to change it. if($this->alreadyInstalled()) { - abort(404); - } + $installedRedirect = config('installer.installedAlreadyAction'); + + switch ($installedRedirect) { + + case 'route': + $routeName = config('installer.installed.redirectOptions.route.name'); + $data = config('installer.installed.redirectOptions.route.message'); + return redirect()->route($routeName)->with(['data' => $data]); + break; + + case 'abort': + abort(config('installer.installed.redirectOptions.abort.type')); + break; + + case 'dump': + $dump = config('installer.installed.redirectOptions.dump.data'); + dd($dump); + break; + + case '404': + case 'default': + default: + abort(404); + break; + } + } return $next($request); } From dd214e0fd24e9e209cbd12571bb93cc87b8322c6 Mon Sep 17 00:00:00 2001 From: jeremykenedy Date: Sun, 16 Jul 2017 22:13:22 -0700 Subject: [PATCH 2/3] change js function name --- readme.md | 1 - src/Views/environment-wizard.blade.php | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/readme.md b/readme.md index 8c776e2..ea7ac0d 100644 --- a/readme.md +++ b/readme.md @@ -32,7 +32,6 @@ The current features are : * [Laravel 5.1, 5.2, 5.3, 5.4 or newer](https://laravel.com/docs/installation) - ## Installation 1. From your projects root folder in terminal run: diff --git a/src/Views/environment-wizard.blade.php b/src/Views/environment-wizard.blade.php index 58ea899..afbe2b7 100644 --- a/src/Views/environment-wizard.blade.php +++ b/src/Views/environment-wizard.blade.php @@ -54,7 +54,7 @@ - @@ -505,7 +505,7 @@ @section('scripts')