<?php

namespace frontend\models;

use Yii;
use common\helpers\Utils;

/**
 * This is the model class for table "bit_lotto_record".
 *
 * @property integer $id
 * @property string $mobile
 * @property string $lottery
 * @property string $activity_type
 * @property integer $in_time
 */
class LottoRecord extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'bit_lotto_record';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['in_time'], 'safe'],
            [['mobile', 'lottery', 'activity_type'], 'required'],
            ['mobile', function ($attribute, $params) {
                if (!Utils::checkPhoneNumber($this->$attribute)) {
                    $this->addError($attribute, '手机号码不正确');
                }
            }],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'mobile' => '手机号码',
            'lottery' => '中奖情况',
            'activity_type' => '活动类型',
            'in_time' => '创建时间',
        ];
    }
}