<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "rejected_requests_causes".
 *
 * @property string $id
 * @property int $training_request_id
 * @property string $rejection_causes
 * @property string $rejection_date
 * @property string $request_status_when_rejected
 * @property int $rejector_user_id
 *
 * @property Users $rejectorUser
 * @property TrainingRequests $trainingRequest
 */
class RejectedRequestsCauses extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'rejected_requests_causes';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['training_request_id', 'rejection_causes', 'rejection_date', 'rejector_user_id', 'request_status_when_rejected'], 'required'],
            [['training_request_id', 'rejector_user_id'], 'integer'],
            [['rejection_causes'], 'string'],
            [['rejection_date'], 'safe'],
            [['rejector_user_id'], 'exist', 'skipOnError' => true, 'targetClass' => Users::className(), 'targetAttribute' => ['rejector_user_id' => 'id']],
            [['training_request_id'], 'exist', 'skipOnError' => true, 'targetClass' => TrainingRequests::className(), 'targetAttribute' => ['training_request_id' => 'id']],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', 'ID'),
            'training_request_id' => Yii::t('app', 'Training Request ID'),
            'rejection_causes' => Yii::t('app', 'Rejection Causes'),
            'rejection_date' => Yii::t('app', 'Rejection Date'),
            'rejector_user_id' => Yii::t('app', 'Rejector User'),
            'request_status_when_rejected' => Yii::t('app', 'Request Status When Rejected'),
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getRejectorUser()
    {
        return $this->hasOne(Users::className(), ['id' => 'rejector_user_id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getTrainingRequest()
    {
        return $this->hasOne(TrainingRequests::className(), ['id' => 'training_request_id']);
    }
}
