<?php

namespace common\models\ars;

use Yii;
use yii\behaviors\TimestampBehavior;

/**
 * This is the model class for table "ats_tem_file".
 *
 * @property int $id
 * @property int $user_id 父级id
 * @property string $name 名称
 * @property int $type 类型
 * @property string $alias 别名
 * @property string $path 地址
 * @property int $updated_at 更新时间
 * @property int $created_at 创建时间
 */
class TemFile extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'ats_tem_file';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['user_id', 'type'], 'integer'],
            [['name', 'path'], 'string', 'max' => 255],
            [['alias'], 'string', 'max' => 50],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'id',
            'user_id' => '父级id',
            'name' => '名称',
            'type' => '类型',
            'alias' => '别名',
            'path' => '地址',
            '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();
                },
            ],
        ];
    }
}