<?php

namespace backend\modules\ecommerce\models;

use Yii;

use yii\db\Expression;
use yii\behaviors\TimestampBehavior;
use yii\behaviors\BlameableBehavior;

/**
 * This is the model class for table "coupon_type".
 *
 * @property integer $id
 * @property string $name
 * @property integer $discount_in_percent
 * @property integer $kickback_in_percent
 * @property integer $validation_type
 * @property integer $status
 * @property integer $created_at
 * @property integer $created_by
 * @property integer $updated_at
 * @property integer $updated_by
 */
class CouponType extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'coupon_type';
    }
    
    public function behaviors(){
		
		return [
            [
                'class' => BlameableBehavior::className(),
                'createdByAttribute' => 'created_by',
                'updatedByAttribute' => 'updated_by',
            ],
			[
				'class' => TimestampBehavior::className(),
				'createdAtAttribute' => 'created_at',
				'updatedAtAttribute' => 'updated_at',
				'value' => new Expression('UNIX_TIMESTAMP(NOW())'),
			]
		];
		
	}

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['name', 'discount_in_percent', 'kickback_in_percent', 'validation_type', 'status'], 'required'],
            [['discount_in_percent', 'kickback_in_percent', 'validation_type', 'status', 'created_at', 'created_by', 'updated_at', 'updated_by'], 'integer'],
            [['name'], 'string', 'max' => 50]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'name' => 'Name',
            'discount_in_percent' => 'Discount In Percent',
            'kickback_in_percent' => 'Kickback In Percent',
            'validation_type' => 'Validation Type',
            'status' => 'Status',
            'created_at' => 'Created At',
            'created_by' => 'Created By',
            'updated_at' => 'Updated At',
            'updated_by' => 'Updated By',
        ];
    }
}
