PHP code example of marvinrabe / laravel-wizards

1. Go to this page and download the library: Download marvinrabe/laravel-wizards 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/ */

    

marvinrabe / laravel-wizards example snippets


Route::wizard('order', OrderWizardController::class);



namespace App\Http\Controllers;

use Illuminate\Http\Request;
use MarvinRabe\LaravelWizards\Wizard;
use MarvinRabe\LaravelWizards\WizardController;

class OrderWizardController extends WizardController
{
    // Prepare a payload. This payload will be available in $wizard->payload on each step. It will be saved
    // automatically after each step{number}Submit method. It is used to store each partial result until onFinish.
    // The simplest payload is an array. But you could use anything you want. It only needs to be serializable!
    public function preparePayload(Request $request, Wizard $wizard): array
    {
        return [];
    }

    // A step is simply a method with the name step{number}.
    // You can do anything you want! Return a view, redirect to somewhere else, etc.
    public function step1(Request $request, Wizard $wizard): mixed
    {
        return view('order.payment');
    }

    // For each step there might be a submit action with the name step{number}Submit. This will be called on POST.
    // In here you could validate the request and afterwards store it in the prepared payload like so:
    public function step1Submit(Request $request, Wizard $wizard): void
    {
        $request->validate([
            'credit_card' => ['