n Laravel Store JSON Format Data in Database | CodimTh

Please Disable Your Browser Adblock Extension for our site and Refresh This Page!

our ads are user friendly, we do not serve popup ads. We serve responsible ads!

Refresh Page
Skip to main content
On . By CodimTh

Laravel Store JSON Format Data in Database


Create Model and migration

Now generate a model and migration file just running the below command.

php artisan make:model Post -m


public function up()
     Schema::create('posts', function (Blueprint $table) {

After creating and updating the code in your migration file now run the below command and check your database where your show a posts table is created along with users and reset_password tables.

php artisan migrate


Create Controller

Now create a new controller just running the below command.

php artisan make:controller PostController 

After running above command put the below command on it.

namespace App\Http\Controllers;
use App\Post;
use Redirect,Response;
use Illuminate\Http\Request;
class PostController extends Controller
   public function index()
      return view('create');
  public function store(Request $request)
      $data = json_encode($request);

      return back()->withSuccess('Data successfully store in json format');


Riadh Rahmi

Senior Web Developer PHP/Drupal & Laravel

I am a senior web developer, I have experience in planning and developing large scale dynamic web solutions especially in Drupal & Laravel.

Web Posts


Page Facebook