diff --git a/src/Controllers/InstallerController.php b/src/Controllers/InstallerController.php index 458ba7e..3833714 100644 --- a/src/Controllers/InstallerController.php +++ b/src/Controllers/InstallerController.php @@ -78,7 +78,8 @@ public function licenseValidation() }; $license_input_name = $this->license_input_name; - return view('installer::license-validation', compact('license_input_name')); + $is_first_step = $this->isFirstStep(); + return view('installer::license-validation', compact('license_input_name', 'is_first_step')); } public function licenseValidationProcess(Request $request) @@ -109,6 +110,7 @@ public function requiredExtensions() }; return view('installer::begin', [ + 'is_first_step' => $this->isFirstStep(), 'phpVersionInfo' => $this->phpVersionInfo, 'phpExtensions' => $this->phpExtensions, 'supported' => $this->support, @@ -124,7 +126,8 @@ public function basicInformation() return $next_step; }; - return view('installer::basic-information'); + $is_first_step = $this->isFirstStep(); + return view('installer::basic-information', compact('is_first_step')); } public function saveBasicInformation(Request $request) @@ -153,7 +156,8 @@ public function database() return $next_step; }; - return view('installer::database'); + $is_first_step = $this->isFirstStep(); + return view('installer::database', compact('is_first_step')); } public function saveDatabase(Request $request) @@ -205,7 +209,8 @@ public function smtp() }; $smtp_info = config('installer.smtp'); - return view('installer::smtp', ['smtp_info' => $smtp_info]); + $is_first_step = $this->isFirstStep(); + return view('installer::smtp', ['smtp_info' => $smtp_info, 'is_first_step' => $is_first_step]); } public function saveSmtp(Request $request) @@ -244,6 +249,16 @@ public function checkPermissionToGoNextStep(string $step): mixed return true; } + public function isFirstStep() + { + // get the current step + $current_step = $this->getCurrentStep(); + $steps = $this->enabledSteps; + + // find the index of the current step + return array_search($current_step, $steps); + } + public function getNextStep(): string { // get the current step @@ -281,6 +296,32 @@ public function getNextStep(): string } } + public function previous() + { + try { + // get the current step + $current_step = $this->getCurrentStep(); + + $steps = $this->enabledSteps; + + // find the index of the current step + $current_index = array_search($current_step, $steps); + + // get the next step + $previous_step = $steps[$current_index - 1]; + + // define file name + $filePath = storage_path('framework/installer-step.php'); + // create the file + file_put_contents($filePath, $previous_step); + + return $this->begin(); + } catch (\Throwable $th) { + + return $this->begin(); + } + } + public function getCurrentStep() { return file_exists(storage_path('framework/installer-step.php')) ? file_get_contents(storage_path('framework/installer-step.php')) : null; diff --git a/src/routes/web.php b/src/routes/web.php index 62c1b64..028add2 100644 --- a/src/routes/web.php +++ b/src/routes/web.php @@ -18,4 +18,5 @@ Route::post('/smtp', 'saveSmtp')->name('installer.smtp.save'); Route::post('/next-step', 'fetchNextStep')->name('installer.next-step'); + Route::get('/previous', 'previous')->name('installer.previous'); }); diff --git a/src/views/basic-information.blade.php b/src/views/basic-information.blade.php index 384d590..b2772a9 100644 --- a/src/views/basic-information.blade.php +++ b/src/views/basic-information.blade.php @@ -35,7 +35,13 @@ --}} -
+
+ @if ($is_first_step !== 0) + + Previous + + @endif diff --git a/src/views/begin.blade.php b/src/views/begin.blade.php index 47b2b1a..abb3242 100644 --- a/src/views/begin.blade.php +++ b/src/views/begin.blade.php @@ -62,7 +62,13 @@ @endif -
+ -
+
+ @if ($is_first_step !== 0) + + Previous + + @endif diff --git a/src/views/license-validation.blade.php b/src/views/license-validation.blade.php index 042289f..989ccaf 100644 --- a/src/views/license-validation.blade.php +++ b/src/views/license-validation.blade.php @@ -18,7 +18,13 @@ {{ $message }} @enderror
-
+
+ @if ($is_first_step !== 0) + + Previous + + @endif diff --git a/src/views/smtp.blade.php b/src/views/smtp.blade.php index 8a8ab94..85ec40d 100644 --- a/src/views/smtp.blade.php +++ b/src/views/smtp.blade.php @@ -16,7 +16,13 @@ value="{{ Environment::pull($smtp['key']) }}">
@endforeach -
+
+ @if ($is_first_step !== 0) + + Previous + + @endif