restaurantName = $restaurantName; $this->googlePlaceApiKey = $googlePlaceApiKey; } public function handle() { // $client = new Client(); // $url = 'https://maps.googleapis.com/maps/api/place/findplacefromtext/json'; // $response = $client->get($url, [ // 'query' => [ // 'fields' => 'place_id', // 'input' => $this->restaurantName, // 'inputtype' => 'textquery', // 'key' => $this->googlePlaceApiKey // ] // ]); // $placeData = json_decode($response->getBody(), true); // if (isset($placeData['candidates'][0]['place_id'])) { // $placeId = $placeData['candidates'][0]['place_id']; // $url = 'https://maps.googleapis.com/maps/api/place/details/json'; // $response = $client->get($url, [ // 'query' => [ // 'fields' => 'opening_hours', // 'place_id' => $placeId, // 'key' => $this->googlePlaceApiKey // ] // ]); // $data = json_decode($response->getBody(), true); // if (isset($data['result']['opening_hours']['weekday_text'])) { // $hours = $data['result']['opening_hours']['weekday_text']; // Cache::put('restaurant_hours_' . $this->restaurantName, $hours, now()->addHours(24)); // } else { // Cache::put('restaurant_hours_' . $this->restaurantName, "N/A", now()->addHours(24)); // } // } else { // Cache::put('restaurant_hours_' . $this->restaurantName, "N/A", now()->addHours(24)); // } } }