Seeding a Json in Laravel

0

Laravel 5.3 allows migrations with json $ table-> json ('links_normal');

But in the seed

DB::table('courses')->insert([
          'name' => 'Curso Nuevo',
          "links_normales": {
            "Opcion 1": "xd",
            "Opcion 2": "red"
          }
        ]);

When I try to make that seed come out:  syntax error, unexpected '{', expecting ']'

The factory I have this

$factory->define(App\Course::class, function (Faker\Generator $faker) {
return [
    'name' => $faker->name,
    'links_normales' => $faker->name,
];

});

The problem is how the json added to the seed

    
asked by ztvmark 08.03.2017 в 06:21
source

1 answer

0

The correct way would be like this:

DB::table('courses')->insert([
          'name' => 'Curso Nuevo',
          "links_normales": '{"Opcion 1": "xd","Opcion 2": "red"}'
        ]);
    
answered by 23.03.2017 в 06:54