<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "trade_logs".
 *
 * @property integer $id
 * @property integer $auk_id
 * @property string $date
 * @property string $comment
 * @property integer $user_id
 */
class Trade extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'trade_logs';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['auk_id', 'user_id'], 'integer'],
            [['date'], 'safe'],
            [['comment'], 'string', 'max' => 255]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', 'ID'),
            'auk_id' => Yii::t('app', 'Auk ID'),
            'date' => Yii::t('app', 'Date'),
            'comment' => Yii::t('app', 'Comment'),
            'user_id' => Yii::t('app', 'User ID'),
        ];
    }
    public function fields()
    {
        return
            [
                'id',
                'auk_id',
                'date',
                'comment',
                'user_id',
            ];
    }

    public function getUser(){
        return $this->hasOne(User::className(), ['id' => 'user_id']);
    }

    public function getAt_org(){
        return $this->user->at_org;
    }
}
