<?php

namespace common\models;

use Yii;
use yii\helpers\ArrayHelper;

/**
 * This is the model class for table "sys_ip_t".
 *
 * @property integer $id
 * @property string $ip
 * @property string $city_name
 */
class SysIpT extends \common\models\Base
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'sys_ip_t';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['ip', 'city_name'], 'string', 'max' => 200],
            [['city_name'], 'required','message'=>'城市名称不能为空'],
            [['city_name'], 'unique','message'=>'城市不能重复'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'ip' => 'Ip',
            'city_name' => '城市名称',
        ];
    }

    /**
     * 返回ip数组
     * 返回ip数组
     * @param 参数
     * @return 返回类型
     * @author liukangle
     *
     */
    static public function getIpArray(){

        $list = self::find()
            ->orderBy('id ASC')
            ->all();

        $array = ArrayHelper::getColumn($list,'ip');

        return $array;
    }
}
