OrdersAudit.php 1.28 KB
<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "orders_audit".
 *
 * @property integer $id
 * @property string $email
 * @property string $phone
 * @property string $comment
 * @property integer $created
 * @property string $ip
 */
class OrdersAudit extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'orders_audit';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['phone', 'comment'], 'required'],
            [['comment'], 'string'],
            [['created'], 'integer'],
            [['email', 'phone'], 'string', 'max' => 150],
            [['ip'], 'string', 'max' => 15]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', 'ID'),
            'email' => Yii::t('app', 'Email'),
            'phone' => Yii::t('app', 'Phone'),
            'comment' => Yii::t('app', 'Comment'),
            'created' => Yii::t('app', 'Created'),
            'ip' => Yii::t('app', 'Ip'),
        ];
    }

	public function setDefaults() {
		$this->ip = Yii::$app->request->getUserIP();
		$this->created = time();
	}

	public function sendEmail($to) {

	}
}