PHP code example of lexal / laravel-stepped-form-submitter

1. Go to this page and download the library: Download lexal/laravel-stepped-form-submitter 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/ */

    

lexal / laravel-stepped-form-submitter example snippets


$app->register(Lexal\LaravelSteppedFormSubmitter\ServiceProvider\ServiceProvider::class);

   'transaction_class' => DatabaseTransaction::class,
   

   'submitters' => [
       // list of form submitters
   ],
   

   use Lexal\FormSubmitter\Transaction\TransactionInterface;
   
   final class DatabaseTransaction implements TransactionInterface
   {
        public function start(): void
        {
            // start transaction
        }
   
        public function commit(): void
        {
            // commit transaction
        }
   
        public function rollback(): void
        {
            // rollback transaction
        }
   }
   

   use Lexal\FormSubmitter\FormSubmitterInterface;
   
   final class CustomerFormSubmitter implements FormSubmitterInterface
   {
       public function supportsSubmitting(mixed $entity): bool
       {
           return $entity instanceof Customer;
       }
       
       public function submit(mixed $entity): mixed
       {
           // save entity to the database
           
           return $entity;
       }
   }
   

   return [
       'transaction_class' => DatabaseTransaction::class,
       'submitters' => [
           CustomerFormSubmitter::class,
       ],
   ];
   
shell
php artisan vendor:publish --provider="Lexal\LaravelSteppedFormSubmitter\ServiceProvider\ServiceProvider"