1. Go to this page and download the library: Download james.rus52/laravel-wizard library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
class InformationStepWizard extends \jamesRUS52\Laravel\Step
{
public function process(Request $request)
{
$this->saveProgress($request);
}
public function getAuxData(): array
{
return [
'owners' => 'Some extra data for view on this step',
];
}
public function rules(Request $request = null): array
{
return [
'owner' => '
class CreationRequestsController extends Controller
{
protected Wizard $wizard;
public function __construct()
{
$this->wizard = new Wizard('Request wizard', [
new InformationStepWizard('information', 'Information', 'requests.create.information-step-wizard'),
new RequestTypeStepWizard('request-type', 'Request type', 'requests.create.request-type-step-wizard'),
new ResourcesStepWizard('resources', 'Choose resources', 'requests.create.resources-step-wizard'),
new ConfirmationStepWizard('confirmation', 'Confirmation', 'requests.create.confirmation-step-wizard'),
],
'creation-request'
);
}
public function create($step_slug = null)
{
try {
if (is_null($step_slug)) {
$step = $this->wizard->firstOrLastProcessed();
} else {
$step = $this->wizard->getBySlug($step_slug);
}
} catch (StepNotFoundException $e) {
abort(404);
}
return view('requests.create.layout-wizard',
array_merge([
'type' => 'creation',
],
$step->getAuxData(),
)
);
}
public function store(Request $request, $step_slug = null)
{
try {
$step = $this->wizard->getBySlug($step_slug);
} catch (StepNotFoundException $e) {
abort(404);
}
$this->validate($request, $step->rules($request));
$step->process($request);
if ($this->wizard->hasNext()) {
return redirect()->route('requests.create.', [$this->wizard->nextStep(false)->slug]);
}
// Finaly Create Request
$full_wizard_data = $this->wizard->data();
$this->wizard->clearProgress();
return redirect()->route('requests.index');
}
}