I suggest make related tables. Storing json is a bad idea.
Nov 22, 2022
5
Level 1
How can I save the JSON data to the database?
I'm using a Google Place API package and I want to get the reviews of the place. And to store this data in the database so that there is no need to call the API on every page visit.
I get the JSON response perfectly, but I don't know how to save the different values to the database. I don't want to save the entire JSON response, only the ones I need, e.g. review text, author name, avatar img etc. This is my controller:
public function index()
{
$response = \GoogleMaps::load('placedetails')
->setParam ([
'placeid' =>'***',
'reviews_no_translations' => 'true',
'reviews_sort' => 'newest'
])
->get();
$reviews = collect(json_decode($response, true));
return view('contact', compact('reviews'));
}
Thank you in advance for your help :)
Please or to participate in this conversation.