Skip to content
This repository has been archived by the owner on Nov 27, 2019. It is now read-only.

Commit

Permalink
Merge pull request #2 from jmaurer1994/master
Browse files Browse the repository at this point in the history
Adding support for getDailyWeatherForecast
  • Loading branch information
gitllermopalafox authored May 20, 2017
2 parents 0fbeefe + 8a395eb commit c7d52a5
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/LaravelOWM.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,39 @@ public function getWeatherForecast($query, $lang = 'en', $units = 'metric', $day
return $owm->getWeatherForecast($query, $units, $lang, '', $days);
}

/**
* Get the daily forecast of the requested location/city.
*
*
*
* There are three ways to specify the place to get weather information for:
* - Use the city name: $query must be a string containing the city name.
* - Use the city id: $query must be an integer containing the city id.
* - Use the coordinates: $query must be an associative array containing the 'lat' and 'lon' values.
*
* @param array|int|string $query
* @param string $lang
* @param string $units
* @param int $days
* @param bool $cache
* @param int $time
* @return OpenWeatherMap\WeatherForecast
*/
public function getDailyWeatherForecast($query, $lang = 'en', $units = 'metric', $days = 5, $cache = false, $time = 600)
{
$lang = $lang ?: 'en';
$units = $units ?: 'metric';
$days = $days ?: 6;

if ($cache) {
$owm = new OpenWeatherMap($this->api_key, null, new Cache(), $time);
return $owm->getDailyWeatherForecast($query, $units, $lang, '', $days);
}

$owm = new OpenWeatherMap($this->api_key);
return $owm->getDailyWeatherForecast($query, $units, $lang, '', $days);
}

/**
* Returns the weather history for the place you specified.
*
Expand Down

0 comments on commit c7d52a5

Please sign in to comment.