PHP code example of wdelfuego / nova-wizard

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

    

wdelfuego / nova-wizard example snippets


    use App\Nova\Wizards\AddUserWizard;

    return [
        'add-user' => [
            'class' => AddUserWizard::class,
            'uri' => 'wizard/add-user',
            'windowTitle' => 'Add user'
        ]
    ];
    

		public function tools()
		{
			return [
				new NovaWizard('add-user')
			];
		}
		

		MenuItem::link('Add a user', NovaWizard::pathToWizard('add-user'))
		

            use Laravel\Nova\Fields;

			public function wizardViewData() : array {
                return [
                    'steps' => [
                        [
                            'title'  => 'Step 1/2',
                            'fields' => [
                                Fields\Text::make(__('Username'), 'username'),
                                Fields\Text::make(__('Text field'), 'myText'),
                                Fields\Textarea::make(__('Longer text'), 'myLongerText')
                                    ->help("You can use Help texts on Nova fields like you're used to"),
                                Fields\Number::make(__('Some number'), 'myNumber')
                                    ->rules('s('

			public function onSubmit($formData, &$context) : bool {
				//
				// When this method gets called, a valid and complete wizard was submitted.
				//
				// $formData is an array that contains the data submitted by the user.
				//
				// $context is an empty array that you can store arbitrary info in;
				// it will be passed to the next method so you can use it
				// to display specific context info to the user on success.
				
				// Parse submitted wizard data somehow
				$user = User::create(['name' => $formData['username']]);
				$context['newUserId'] = $user->id;

				// Return true at the end of this method to indicate success
				return true;

				// Or return false if the data can not be parsed successfully;
				// the user will then stay in the form view and have a chance
				// to revise the data before resubmitting.
			}
    		

			public function successViewData($context) : array {
        
				return [
					'message' => 'Successfully created user with id: ' .$context['newUserId']
				];
			}
    		
sh
    php artisan vendor:publish --provider="Wdelfuego\NovaWizard\ToolServiceProvider" --tag="config"