PHP code example of bnhashem / form-data

1. Go to this page and download the library: Download bnhashem/form-data 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/ */

    

bnhashem / form-data example snippets


use Bnhashem\FormData\FormData;

$formData = new FormData();

use Bnhashem\FormData\FormData;

/**
 * Show the form for creating a new resource.
 *
 * @return \Illuminate\Http\Response
 */
public function create()
{
    return view('your.custom.view', FormData::old(new Model()));
}

use Bnhashem\FormData\FormData;

/**
 * Show the form for editing the specified resource.
 *
 * @param  \App\Models\Model $model
 * @return \Illuminate\Http\Response
 */

public function edit(Model $model)
{
    return view('your.custom.view', FormData::edit($model);
}

/**
 * Run the migrations.
 *
 * @return void
 */
public function up()
{
    Schema::create('posts', function (Blueprint $table) {
        $table->id();
        $table->string('name');
        $table->string('content');
        $table->timestamps();
    });
}

use Bnhashem\FormData\FormData;

public function create()
{
    return view('your.custom.view', FormData::old(new Post()));
}

use Bnhashem\FormData\FormData;

public function edit(Post $post)
{
    return view('your.custom.view', FormData::edit($post));
}

public function up()
{
    Schema::create('posts', function (Blueprint $table) {
        $table->id();
        $table->json('name');
        $table->json('content');
    });
}

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Post extends Model
{

    public static $JSONCOLUMNS = [
        'name' => ['en', 'ar'], 
        'content' => ['ar', 'en']
        ];

}