Skip to content

Commit

Permalink
feat: previos step added
Browse files Browse the repository at this point in the history
  • Loading branch information
devzkhalil committed Aug 2, 2024
1 parent 66c80b1 commit 54f1c18
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 9 deletions.
49 changes: 45 additions & 4 deletions src/Controllers/InstallerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
8 changes: 7 additions & 1 deletion src/views/basic-information.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@
</label>
<input type="text" class="form-control" id="APP_ENV" name="APP_ENV" value="{{ config('app.env') }}">
</div> --}}
<div class="form-group text-center mt-5">
<div
class="form-group text-center mt-5 d-flex {{ $is_first_step == 0 ? 'justify-content-center' : 'justify-content-between' }} align-items-center">
@if ($is_first_step !== 0)
<a href="{{ route('installer.previous') }}" class="btn btn-info loader-show">
Previous
</a>
@endif
<button type="submit" class="btn btn-success loader-show">
Click To Complete
</button>
Expand Down
8 changes: 7 additions & 1 deletion src/views/begin.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,13 @@
@endif
</tbody>
</table>
<div class="text-center">
<div
class="form-group text-center mt-5 d-flex {{ $is_first_step == 0 ? 'justify-content-center' : 'justify-content-between' }} align-items-center">
@if ($is_first_step !== 0)
<a href="{{ route('installer.previous') }}" class="btn btn-info loader-show">
Previous
</a>
@endif
@if ($supported)
<a href="{{ $next_step_url }}" class="btn btn-success loader-show">
Click To Complete
Expand Down
8 changes: 7 additions & 1 deletion src/views/database.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,13 @@
<input type="text" class="form-control" id="DB_PASSWORD" name="DB_PASSWORD"
value="{{ config('database.connections.' . config('database.default') . '.password') }}">
</div>
<div class="form-group text-center mt-5">
<div
class="form-group text-center mt-5 d-flex {{ $is_first_step == 0 ? 'justify-content-center' : 'justify-content-between' }} align-items-center">
@if ($is_first_step !== 0)
<a href="{{ route('installer.previous') }}" class="btn btn-info loader-show">
Previous
</a>
@endif
<button type="submit" class="btn btn-success loader-show">
Click To Complete
</button>
Expand Down
8 changes: 7 additions & 1 deletion src/views/license-validation.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@
<strong>{{ $message }}</strong></span>
@enderror
</div>
<div class="form-group text-center mt-5">
<div
class="form-group text-center mt-5 d-flex {{ $is_first_step == 0 ? 'justify-content-center' : 'justify-content-between' }} align-items-center">
@if ($is_first_step !== 0)
<a href="{{ route('installer.previous') }}" class="btn btn-info loader-show">
Previous
</a>
@endif
<button type="submit" class="btn btn-success loader-show">
Click To Complete
</button>
Expand Down
8 changes: 7 additions & 1 deletion src/views/smtp.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@
value="{{ Environment::pull($smtp['key']) }}">
</div>
@endforeach
<div class="form-group text-center mt-5">
<div
class="form-group text-center mt-5 d-flex {{ $is_first_step == 0 ? 'justify-content-center' : 'justify-content-between' }} align-items-center">
@if ($is_first_step !== 0)
<a href="{{ route('installer.previous') }}" class="btn btn-info loader-show">
Previous
</a>
@endif
<button type="submit" class="btn btn-success loader-show">
Click To Complete
</button>
Expand Down

0 comments on commit 54f1c18

Please sign in to comment.