/** * Returns a collection of all networks and it's count. * * @return mixed */ public function networkDistribution() { $this->createSqliteRegexpFunction(); $data = Poke::select(DB::raw("\n CASE\n WHEN ip LIKE '192.168.%'\n THEN '192.168.0.0/16'\n WHEN (ip REGEXP '/^172\\.(1[6-9]|2[0-9]|3[01])\\./')\n THEN '172.16.0.0/12'\n WHEN ip LIKE '10.%'\n THEN '10.0.0.0/8'\n ELSE 'Internet'\n END\n\t\tAS label, count(*) as value"))->groupBy('label')->orderBy('label')->get(); return $this->addColors($data); }