1. Go to this page and download the library: Download ycs77/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/ */
ycs77 / laravel-wizard example snippets
use App\Http\Controllers\UserWizardController;
use Illuminate\Support\Facades\Route;
use Ycs77\LaravelWizard\Facades\Wizard;
...
Wizard::routes('/wizard/user', UserWizardController::class, 'wizard.user');
namespace App\Steps\User;
use App\User;
use Illuminate\Http\Request;
use Illuminate\Support\Arr;
use Ycs77\LaravelWizard\Step;
class NameStep extends Step
{
/**
* The step slug.
*
* @var string
*/
protected $slug = 'name';
/**
* The step show label text.
*
* @var string
*/
protected $label = 'Name';
/**
* Set the step model instance or the relationships instance.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Relations\Relation|null
*/
public function model(Request $request)
{
return User::find(1);
}
/**
* Save this step form data.
*
* @param \Illuminate\Http\Request $request
* @param array|null $data
* @param \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Relations\Relation|null $model
* @return void
*/
public function saveData(Request $request, $data = null, $model = null)
{
$data = Arr::only($data, 'name');
$model->update($data);
}
/**
* Validation rules.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function rules(Request $request)
{
return [
'name' => 'reqred',
];
}
}