You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

91 lines
2.0 KiB

<?php
namespace backend\modules\shop\models\ars;
use Yii;
use yii\behaviors\TimestampBehavior;
/**
* This is the model class for table "ats_express_template".
*
* @property int $id
* @property string $name 名称
* @property int $updated_at 更新时间
* @property int $created_at 创建时间
* @property int $calculation_type 计算方式
*/
class ExpressTemplate extends \yii\db\ActiveRecord
{
//计算方式calculation_type
const CALCULATION_TYPE_WEIGHT = 1; //按重量
const CALCULATION_TYPE_NUMBER = 2; //按件数
public static $calculationType = [
self::CALCULATION_TYPE_WEIGHT => '按重量',
self::CALCULATION_TYPE_NUMBER => '按件数'
];
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'ats_express_template';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['name'], 'required'],
[['calculation_type'], 'integer'],
[['name'], 'string', 'max' => 255]
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'id',
'name' => '名称',
'updated_at' => '更新时间',
'created_at' => '创建时间',
'calculation_type' => '计算方式',
];
}
/**
* @author linyao
* @email 602604991@qq.com
* @created Nov 8, 2019
*
* 行为存储创建时间和更新时间
*/
public function behaviors()
{
return [
[
'class' => TimestampBehavior::className(),
'createdAtAttribute' => 'created_at',
'updatedAtAttribute' => 'updated_at',
'value' => function() {
return time();
},
],
];
}
/**
* @return array
* 数据键值对
*/
public static function modelColumn()
{
return $column = self::find()->select(['name'])->indexBy('id')->column();
}
}