PHP code example of roundly-consulting / forms-for-laravel

1. Go to this page and download the library: Download roundly-consulting/forms-for-laravel 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/ */

    

roundly-consulting / forms-for-laravel example snippets


use RoundlyConsulting\Forms\Facades\Forms;
use RoundlyConsulting\Forms\GroupBuilder;

Forms::define('contact', 'Contact us')
    ->public()
    ->group('details', 'Your details', function (GroupBuilder $g): void {
        $g->field('name', 'Name')->rules(['

$form = Forms::find('contact');

Forms::validate(form: $form, request: $request);   // throws ValidationException on failure

$result = Forms::submit(form: $form, request: $request, sender: $request->user());
$result->uuid;                                      // the submission's reference id

$answers = Forms::submissions($form)->latest()->get();

$answers->first()->values;   // ['name' => 'Jane', 'email' => '[email protected]', 'body' => 'Hello!']
bash
composer vendor:publish --tag="forms-migrations"
php artisan vendor:publish --tag="approvals-migrations" --tag="attributes-migrations" --tag="media-migrations"
php artisan migrate