private function updateFromOpenExchangeRates($defaultCurrency, $api)
    {
        $this->info('Updating currency exchange rates from OpenExchangeRates.org...');

        // Make request
        $content = json_decode($this->request("http://openexchangerates.org/api/latest.json?base={$defaultCurrency}&app_id={$api}&show_alternative=1"));

        // Error getting content?
        if (isset($content->error)) {
            $this->error($content->description);

            return;
        }

        // Parse timestamp for DB
        $timestamp = (new DateTime())->setTimestamp($content->timestamp);

        // Update each rate
        foreach ($content->rates as $code => $value) {
            $this->currency->getDriver()->update($code, [
                'exchange_rate' => $value,
                'updated_at' => $timestamp,
            ]);
        }

        $this->currency->clearCache();

        $this->info('Update!');
    }
private function updateFromOpenExchangeRates($defaultCurrency, $api)
    {
        $this->info('Updating currency exchange rates from OpenExchangeRates.org...');

        // Make request
        $content = json_decode($this->request("http://openexchangerates.org/api/latest.json?base={$defaultCurrency}&app_id={$api}&show_alternative=1"));

        // Error getting content?
        if (isset($content->error)) {
            $this->error($content->description);

            return;
        }

        // Parse timestamp for DB
        $timestamp = (new DateTime())->setTimestamp($content->timestamp);

        // Update each rate
        foreach ($content->rates as $code => $value) {
            $this->currency->getDriver()->update($code, [
                'exchange_rate' => $value,
                'updated_at' => $timestamp,
            ]);
        }

        $this->currency->clearCache();

        $this->info('Update!');
    }
private function updateFromOpenExchangeRates ( $ defaultCurrency , $ api ) { $ this -> info ( 'Updating currency exchange rates from OpenExchangeRates.org...' ) ; // Make request $ content = json_decode ( $ this -> request ( "http://openexchangerates.org/api/latest.json?base={$defaultCurrency}&app_id={$api}&show_alternative=1" ) ) ; // Error getting content? if ( isset ( $ content -> error ) ) { $ this -> error ( $ content -> description ) ; return ; } // Parse timestamp for DB $ timestamp = ( new DateTime ( ) ) -> setTimestamp ( $ content -> timestamp ) ; // Update each rate foreach ( $ content -> rates as $ code => $ value ) { $ this -> currency -> getDriver ( ) -> update ( $ code , [ 'exchange_rate' => $ value , 'updated_at' => $ timestamp , ] ) ; } $ this -> currency -> clearCache ( ) ; $ this -> info ( 'Update!' ) ; }
Fetch rates from the API

@param $defaultCurrency
@param $api
Fetch rates from the API