<?php

namespace common\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 string $province 省份
 * @property string $city 城市
 * @property string $area 区域
 * @property int $billing_type 账单类型
 * @property int $extra_weight_type 续重重量类型
 * @property int $exemption_type 包邮类型
 * @property int $basic_price 基本运费
 * @property int $extra_price 续重运费
 * @property int $exemption_amount 包邮金额
 * @property int $support_taking 是否支持自提,1为不支持
 * @property string $taking_site 自提地点
 * @property int $updated_at 更新时间
 * @property int $created_at 创建时间
 */
class ExpressTemplate extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'ats_express_template';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['name'], 'required'],
            [['province', 'city', 'area', 'taking_site'], 'string'],
            [['billing_type', 'extra_weight_type', 'exemption_type', 'basic_price', 'extra_price', 'exemption_amount', 'support_taking'], 'integer'],
            [['name'], 'string', 'max' => 255],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'id',
            'name' => '名称',
            'province' => '省份',
            'city' => '城市',
            'area' => '区域',
            'billing_type' => '账单类型',
            'extra_weight_type' => '续重重量类型',
            'exemption_type' => '包邮类型',
            'basic_price' => '基本运费',
            'extra_price' => '续重运费',
            'exemption_amount' => '包邮金额',
            'support_taking' => '是否支持自提,1为不支持',
            'taking_site' => '自提地点',
            'updated_at' => '更新时间',
            'created_at' => '创建时间',
        ];
    }
   

    /**
    * @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();
                },
            ],
        ];
    }
}