<?php

namespace common\models\ars;

use Yii;
use yii\behaviors\TimestampBehavior;

/**
 * This is the model class for table "ats_delivery".
 *
 * @property int $id
 * @property int $order_id 订单id
 * @property string $shipping_name 货流名称
 * @property string $shipping_id 运货单位
 * @property int $type 类型
 * @property string $goods 商品
 * @property int $status 状态
 * @property string $decription 描述
 * @property int $updated_at 更新时间
 * @property int $created_at 创建时间
 */
class Delivery extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'ats_delivery';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['order_id', 'type', 'status'], 'integer'],
            [['shipping_id'], 'required'],
            [['goods', 'decription'], 'string'],
            [['shipping_name'], 'string', 'max' => 50],
            [['shipping_id'], 'string', 'max' => 10],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'id',
            'order_id' => '订单id',
            'shipping_name' => '货流名称',
            'shipping_id' => '运货单位',
            'type' => '类型',
            'goods' => '商品',
            'status' => '状态',
            'decription' => '描述',
            '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();
                },
            ],
        ];
    }
}