Exemplo n.º 1
0
 /**
  * Returns the country analytics
  */
 public function countryAnalytics(Request $request, $id, $rangeFrom, $rangeTo, $unit)
 {
     $url = Url::find($id);
     if (empty($url)) {
         echo 'Not Found';
         return;
     }
     Utility::getUnit($unit);
     $countryData = $url->hits()->whereBetween('created_at', array($rangeFrom, $rangeTo))->select(\DB::raw('count(*) as count, country_iso_code, country'))->groupBy('country_iso_code')->get();
     echo json_encode($countryData);
     return;
 }