Ejemplo n.º 1
0
 /**
  * scope by detail to be used by google maps in dashboard
  * @param  query    $query      query object
  * @return mixed                new query object
  */
 public function scopeMap($query)
 {
     $attrs = ['data_type', 'problem_type', 'code', 'name', 'lat', 'lng', 'tambon_name', 'amphoe_name', 'province_name', 'part', 'basin'];
     // $attrs = ['problem_type', 'code', 'name', 'lat', 'lng', 'tambon_name', 'amphoe_name', 'province_name', 'part', 'basin'];
     $query->join('tele_station', 'problems.station_code', '=', 'tele_station.code')->selectRaw(implode(", ", $attrs) . ', sum(num) as num')->groupBy($attrs);
     return $query;
 }