0

I'm trying to build a website builder, where I want to store HTML structure of the plugins/portlets manually, where user can have the structure and whatever editable data they are inserting, gets stored into database using serialize in the controller, now I came to know MySQL doesn't hold html data or say it is unsafe to store, I decided to store the basic structure into JSON format into a separate file, Now I don't want to have these JSON files in my public folder destination, I went through the Seeder documentation and tutorial to find path of the file and get the JSON data. Also went through this tutorial

and came across following class:

<?php

use Illuminate\Database\Seeder;
use App\User;

class PortletTableSeeder extends Seeder {

   public function run()
   {
      $json = File::get("database/data/portlets.json");
      $data = json_decode($json);
      foreach ($data as $obj) {
          'id' => $obj->id,
          'html_code' => $obj->html_code,
          'dummy_data' => $obj->dummy_data,
          //more objects..
         ));
       }
    }

}

?>

Is it the correct way of executing this? and calling it into blade file for example I have mixstyles by the name if id of the theme/portlet in gulpfile can I have like this:

<link href="css/{{$id}}.css" rel="stylesheet" type="text/css" />
Nitish Kumar
  • 6,054
  • 21
  • 82
  • 148

1 Answers1

1

I think best way to do this is manage HTML code in front end (using blade). Get data set from DB & create dynamic pages in front end.

You can design separate blade files & load in dynamically.

public function create()
{
   $data = Portlet::get();

   if(condition)
       return view('design.form1',compact('data'));
   else
       return view('design.form2',compact('data'));
}

If you want to keep json data in mysql DB please follow the link.

How to Use JSON Data Fields in MySQL Databases

Shanka SMS
  • 644
  • 6
  • 15