Skip to content

HCESrl/laravel-wizartisan

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hcesrl/laravel-wizartisan

Latest Stable Version Total Downloads License

Installation

Install the package:

composer require hcesrl/laravel-wizartisan

Usage

Create your wizard command extending the Wizartisan command. You must implement the configureWizard to add the steps to the wizard and the finish method that receives the validated data and completes the procedure.

<?php
namespace App\Console\Commands;

use Wizartisan\Command;

class CustomCommand extends Command
{
	
	protected function configureWizard ()
	{
		/**
		 * Ask simple question with validation
		 */
		$this->askQuestion ( 'What is your name?' )
			 ->name ( 'name' )
			 ->mustValidate ( 'required' );
		
		/**
		 * Select option from given set
		 */
		$this->askQuestion ( 'Choose your option:' )
			 ->name ( 'option' )
			 ->chooseFrom ( 
			 	[
                    'option1' => 'Option 1',
                    'option2' => 'Option 2',
                    'option3' => 'Option 3',
                ]
		     );
		
		/**
		 * Ask a question with confirmation and hide the answer
		 */
		$this->askQuestion ( 'What is your secret password?' )
			 ->name ( 'password' )
			 ->hideAnswer ()
			 ->withConfirmation ( 'You must confirm your password' );
	}
	
	
	protected function finish ( $data = [] )
	{
		$this->doSomethingWithTheValidInputData ( $data );
		
		return 0;
	}
	
}

License

This package is open-sourced software licensed under the MIT license.

Authors

About

Build your custom Laravel Artisan wizard commands.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages