<?php

namespace common\models;

use Yii;
use yii\web\User;

/**
 * This is the model class for table "order_gift_t".
 *
 * @property integer $id
 * @property integer $order_id
 * @property integer $group_id
 * @property integer $gift_id
 * @property integer $send_id
 * @property integer $send_time
 * @property string $rate
 * @property string $price
 * @property integer $status
 * @property integer $is_free
 * @property integer $gift_type
 * @property string $created_at
 * @property string $updated_at
 */
class OrderGiftT extends \common\models\Base
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'order_gift_t';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['order_id', 'group_id', 'gift_id', 'send_id', 'send_time', 'price', 'status'], 'required'],
            [['order_id', 'group_id', 'gift_id', 'send_id', 'send_time', 'status','is_free','gift_type'], 'integer'],
            [['rate','price'], 'number'],
            [['created_at', 'updated_at'], 'safe'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'order_id' => 'Order ID',
            'group_id' => 'Group ID',
            'gift_id' => 'Gift ID',
            'send_id' => 'Send ID',
            'send_time' => 'Send Time',
            'rate' => 'Rate',
            'price' => 'Price',
            'status' => 'Status',
            'is_free' => 'Is Free',
            'gift_type' => 'Gift Type',
            'created_at' => 'Created At',
            'updated_at' => 'Updated At',
        ];
    }

    public function getOrder()
    {
        return $this->hasOne(OrderT::className(),['id'=>'order_id']);
    }

    public function getSender()
    {
        return $this->hasOne(UserT::className(),['id'=>'send_id']);
    }

    public function getGroup()
    {
        return $this->hasOne(GiftGroupT::className(),['id'=>'group_id']);
    }

    public function getGift()
    {
        return $this->hasOne(GiftT::className(),['id'=>'gift_id']);
    }
}