PHP code example of ac-developers / laravel-form-processor

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

    

ac-developers / laravel-form-processor example snippets


'providers' => [
    AcDevelopers\LaravelFormProcessor\LaravelFormProcessorServiceProvider::class,
    ];

$app->register(AcDevelopers\LaravelFormProcessor\LaravelFormProcessorServiceProvider::class);

'aliases' => [
    'LaravelFormProcessorFacade' => AcDevelopers\LaravelFormProcessor\LaravelFormProcessorFacade::class,
    ];

php artisan vendor:publish --provider="AcDevelopers\LaravelFormProcessor\LaravelFormProcessorServiceProvider"

php artisan generate:process PublishArticleProcess --model=Article

class PublishArticleProcess extends LaravelFormProcess implements LaravelFormProcessableInterface
{
    /**
     * PublishArticleProcess constructor.
     * @param \Illuminate\Http\Request $request
     * @param \App\Article $article
     */
    public function __construct(Request $request, Article $article)
    {
        $this->request = $request;
        $this->model = $article;
    }

    /**
     * @return \Illuminate\Http\Response
     */
    public function handle()
    {
        //
    }
}

class PublishArticleProcess extends LaravelFormProcess implements LaravelFormProcessableInterface
{
    protected $request;

    protected $article;

    /**
     * PublishArticleProcess constructor.
     * @param \Illuminate\Http\Request $request
     * @param \App\Article $article
     */
    public function __construct(Request $request, Article $article)
    {
        $this->request = $request;
        $this->article = $article;
    }

    /**
     * @return \Illuminate\Http\Response
     */
    public function handle()
    {
        // Perform validation using Laravel's ValidatesRequests trait
        $this->validate($this->request, ['published' => '

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Article $article
     * @param LaravelFormProcessorInterface $laravelFormProcessorInterface
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, Article $article, LaravelFormProcessorInterface $formProcessorInterface)
    {
        $process = $formProcessorInterface->retrieveProcessFromFormField($request->get('_prKey'))

        return $formProcessorInterface->run(new $process($request, $article));
    }

/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Article $article
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, Article $article)
    {
        $process = LaravelFormProcessorFacade::retrieveProcessFromFormField($request->get('_prKey'))

        return LaravelFormProcessorFacade::run(new $process($request, $article));
    }