73 lines
1.7 KiB
PHP
73 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace app\models\sms;
|
|
|
|
use Yii;
|
|
use app\components\DbUtils;
|
|
|
|
/**
|
|
* This is the model class for table "{{%sms_country}}".
|
|
*
|
|
* @property int $id ID
|
|
* @property string $iso ISO
|
|
* @property string $iso3 ISO3
|
|
* @property string $name 名称
|
|
* @property string $name_cn 中文名称
|
|
* @property string $nicename 简称
|
|
* @property string $num_code 编码
|
|
* @property string $country_code 国家代码
|
|
* @property int $created_at 添加时间
|
|
*/
|
|
class SmsCountry extends \yii\db\ActiveRecord
|
|
{
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public static function tableName()
|
|
{
|
|
return '{{%sms_country}}';
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function rules()
|
|
{
|
|
return [
|
|
[['iso', 'iso3', 'name', 'name_cn', 'nicename', 'num_code', 'country_code'], 'required'],
|
|
[['created_at'], 'integer'],
|
|
[['iso', 'iso3', 'num_code', 'country_code'], 'string', 'max' => 16],
|
|
[['name', 'name_cn', 'nicename'], 'string', 'max' => 64],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function attributeLabels()
|
|
{
|
|
return [
|
|
'id' => 'ID',
|
|
'iso' => 'ISO',
|
|
'iso3' => 'ISO3',
|
|
'name' => '名称',
|
|
'name_cn' => '中文名称',
|
|
'nicename' => '简称',
|
|
'num_code' => '编码',
|
|
'country_code' => '国家代码',
|
|
'created_at' => '添加时间',
|
|
];
|
|
}
|
|
|
|
public function beforeSave($insert) {
|
|
if(parent::beforeSave($insert)){
|
|
if($this->isNewRecord){
|
|
$this->created_at = time();
|
|
}
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
}
|