<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "interviews".
 *
 * @property string $id
 * @property int $training_request_id
 * @property int $branch_id
 * @property string $date
 * @property int $created_by
 *
 * @property Branches $branch
 * @property Users $createdBy
 * @property TrainingRequests $trainingRequest
 */
class Interviews extends \yii\db\ActiveRecord
{
    public $trainee_full_name;
    public $trainee_mother_name;
    public $create_date;
    public $serial_number;

    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'interviews';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['training_request_id', 'branch_id', 'date', 'created_by'], 'required'],
            [['training_request_id', 'branch_id', 'created_by'], 'integer'],
            [['date'], 'safe'],
            [['branch_id'], 'exist', 'skipOnError' => true, 'targetClass' => Branches::className(), 'targetAttribute' => ['branch_id' => 'id']],
            [['created_by'], 'exist', 'skipOnError' => true, 'targetClass' => Users::className(), 'targetAttribute' => ['created_by' => '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'),
            'branch_id' => Yii::t('app', 'Branch'),
            'date' => Yii::t('app', 'Date'),
            'created_by' => Yii::t('app', 'Created By'),
            'trainee_full_name' => Yii::t('app', 'Trainee Full Name'),
            'trainee_mother_name' => Yii::t('app', 'Trainee Mother Name'),
            'create_date' => Yii::t('app', 'Create Date'),
            'serial_number' => Yii::t('app', 'Serial Number'),
        ];
    }

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

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

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