PHP code example of 64robots / webforms
1. Go to this page and download the library: Download 64robots/webforms 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/ */
64robots / webforms example snippets
use R64\Webforms\QuestionTypes\EmailType;
use R64\Webforms\QuestionTypes\PhoneType;
return [
'date_format' => 'Y-m-d',
'year_month_format' => 'Y-m',
'fields_to_be_confirmed' => [
EmailType::TYPE,
PhoneType::TYPE,
],
'user_model' => 'App\User',
];
Route::webforms('webforms');
Route::webformsAdmin('webforms-admin');
Route::webforms('webforms');
Route::webformsAdmin('webforms-admin');
use R64\Webforms\Models\Form;
$coffeeForm = Form::build('Coffee Form')
->save();
use R64\Webforms\Models\FormStep;
$coffeeStep = FormStep::build($coffeeForm, 'Coffee')
->save();
use R64\Webforms\Models\Question;
use R64\Webforms\QuestionTypes\OptionsType;
$whatKindOfCoffeeDoYouLikeQuestion = Question::build($coffeeStep, 'What kind of coffee do you like?')
->type(OptionsType::TYPE)
->options([
'black' => 'Black',
'latte' => 'Latte',
'capuccino' => 'Cappucino',
'americano' => 'Americano',
'red-eye' => 'Red Eye',
'flat-white' => 'Flat White',
])
->save();
$whatTypeOfBeansDoYouLikeQuestion = Question::build($coffeeStep, 'What type of coffee beans do you like the most?')
->type(OptionsType::TYPE)
->options([
'arabica' => 'Arabica',
'robusta' => 'Robusta',
])
->save();
use R64\Webforms\Models\FormStep;
$personalInfoStep = FormStep::build($coffeeForm, 'Personal info')
->isPersonalData(1)
->save();
use R64\Webforms\Models\Question;
use R64\Webforms\QuestionTypes\IntegerType;
$firstNameQuestion = Question::build($personalInfoStep, 'First Name')
->save();
$lastNameQuestion = Question::build($personalInfoStep, 'Last Name')
->save();
$ageQuestion = Question::build($personalInfoStep, 'Birth Year')
->type(IntegerType::TYPE)
->save();
User::all()->each->addFormSteps([$coffeeStep, $personalInfoStep]);
User::all()->each->addFormSteps();
bash
php artisan vendor:publish --provider="R64\Webforms\WebformsServiceProvider" --tag="migrations"
php artisan migrate
bash
php artisan vendor:publish --provider="R64\Webforms\WebformsServiceProvider" --tag="config"
php artisan make:seeder CoffeeSeeder