<?php
/**
 * Created by PhpStorm.
 * User: xiaofeng
 * Date: 2018/3/4
 * Time: 上午9:31
 */

namespace common\models;

//use yii\db\ActiveRecord;
//use yii\behaviors\TimestampBehavior;
class Config extends Common
{
//        public function behaviors()
//        {
//            return [
//                [
//                    'class' => TimestampBehavior::className(),
//                    'attributes' => [
//                        # 创建之前
//                        ActiveRecord::EVENT_BEFORE_INSERT => ['create_at', 'update_at'],
//                        # 修改之前
//                        ActiveRecord::EVENT_BEFORE_UPDATE => ['update_at']
//                    ],
//                    #设置默认值
//                    'value' => $_SERVER['REQUEST_TIME']
//                ]
//            ];
//        }

    public function rules()
    {
        return [
            ['title', 'required', 'message' => '不能为空'],
            ['tel', 'string', 'max' => 20],
            [['wechat', 'logo', 'email', 'title', 'record', 'operating_hours'], 'string', 'max' => 50],
            [['keywords', 'bridge_code', 'statistics', 'm_statistics', 'master_360', 'bridge_link', 'description', 'disclaimer'], 'string', 'max' => 100000]
        ];
    }

    public function attributeLabels()
    {
        return [
            'title' => '网站标题',
            'keywords' => '网站关键词',
            'description' => '网站描述',
            'wechat' => '微信二维码',
            'logo' => '网站logo',
            'tel' => '服务电话',
            'email' => 'E-mail',
            'record' => '备案号',
            'bridge_link' => '53快服',
            'operating_hours' => '工作时间',
            'baidu_ak' => '百度地图ak',
            'bridge_code' => '商桥代码',
            'statistics' => 'PC端友盟代码',
            'm_statistics' => '移动端友盟代码',
            'master_360' => '360站长代码',
            'disclaimer' => '免责声明',
        ];
    }

    public function FindById()
    {
        return self::find()->one();
    }

}