Ejemplo n.º 1
0
 /**
  * Api function for crawl exrates.
  *
  * @return Response
  */
 public function getExrates()
 {
     $records = Currency::whereRaw('crawl = ? AND type = ?', array(false, 'CURRENCY'))->take(10)->get();
     if (!count($records)) {
         Currency::where('crawl', '=', true)->update(array('crawl' => false));
         $records = Currency::whereRaw('crawl = ? AND type = ?', array(false, 'CURRENCY'))->take(10)->get();
     }
     // Crawl data
     foreach ($records as $record) {
         if (CurrencyDaily::updatePriceDaily($record->id, $record->code, 'currency')) {
             $record->crawl = true;
             $record->save();
         }
     }
     return Response::json(array('status' => 'success', 'data' => $records), 200);
 }