Skip to content

Commit

Permalink
Add step parameter for Wizardable hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
ycs77 committed Sep 10, 2024
1 parent 01f83ea commit 8abc38f
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/Wizardable.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function store(Request $request, string $step)
$step = $this->getWizardStep($request, $step);

// If trigger from 'back', set this step index and redirect to prev step.
if ($request->query('_trigger') === 'back' && $this->beforeBackWizardStep($request)) {
if ($request->query('_trigger') === 'back' && $this->beforeBackWizardStep($request, $step)) {
if ($this->wizard()->option('cache')) {
$step->cacheProgress($request);
}
Expand All @@ -124,7 +124,7 @@ public function store(Request $request, string $step)
);

// Wizard step validated event.
$this->wizardStepFormValidated($request);
$this->wizardStepFormValidated($request, $step);
}

if ($this->wizard()->option('cache')) {
Expand Down Expand Up @@ -226,18 +226,18 @@ protected function canValidate(Request $request)
}

/**
* Step redirect response.
* Redirect to the step.
*
* @param string|null $step
* @param string|null $stepSlug
* @return \Illuminate\Http\RedirectResponse
*/
protected function redirectTo($step = null)
protected function redirectTo(string $stepSlug = null)
{
if (is_null($step)) {
$step = $this->getNextStepSlug();
if (is_null($stepSlug)) {
$stepSlug = $this->getNextStepSlug();
}

return redirect($this->getActionUrl('create', [$step]));
return redirect($this->getActionUrl('create', [$stepSlug]));
}

/**
Expand Down Expand Up @@ -529,9 +529,10 @@ protected function beforeWizardStepSave(Request $request)
* On wizard step validated event.
*
* @param \Illuminate\Http\Request $request
* @param \Ycs77\LaravelWizard\Step $step
* @return void
*/
protected function wizardStepFormValidated(Request $request)
protected function wizardStepFormValidated(Request $request, Step $step)
{
//
}
Expand All @@ -552,9 +553,10 @@ protected function wizardStepSaved(Request $request, Step $step)
* On before back wizard step event.
*
* @param \Illuminate\Http\Request $request
* @param \Ycs77\LaravelWizard\Step $step
* @return bool
*/
protected function beforeBackWizardStep(Request $request)
protected function beforeBackWizardStep(Request $request, Step $step)
{
return true;
}
Expand Down

0 comments on commit 8abc38f

Please sign in to comment.