samedi 24 juillet 2021

Error when saving json to database mysql?

public function store(Request $request)
{
  $image = ['http://localhost.loca/image/product/01-1627140249.jpg', 'http://localhost.loca/image/product/03-169983334.jpg'];
  $product = new Product();
  $product->image = json_encode($image);
  $product->save();
}

And the results are stored in the database

["http:\/\/localhost.loca\/image\/product\/01-1627140249.jpg","http:\/\/localhost.loca\/image\/product\/03-169983334.jpg"]

There are \ being generated. is there any fix. Thanks.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire