Exemplo n.º 1
0
 /**
  * query ip division
  * @return null|string[] null or division array
  */
 public function query()
 {
     if ($this->validate()) {
         $ip = ip2long($this->ip);
         $results = [];
         foreach (['full' => Full::className(), 'mini' => Mini::className(), 'china' => China::className(), 'world' => World::className()] as $name => $index) {
             $results[$name] = $this->getResultFromModel($index, $ip);
         }
         return $results;
     }
     return null;
 }
Exemplo n.º 2
0
 /**
  * @param $type
  * @return Full|Mini|China|World
  * @throws NotFoundHttpException
  */
 protected function getIndexClass($type)
 {
     switch ($type) {
         case 'full':
             return Full::className();
         case 'mini':
             return Mini::className();
         case 'china':
             return China::className();
         case 'world':
             return World::className();
         default:
             throw new NotFoundHttpException("Type {$type} not found");
     }
 }
Exemplo n.º 3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getMini()
 {
     return $this->getIndex(Mini::className());
 }