<?php

namespace modules\custom\models;


use Yii;
use yii\behaviors\BlameableBehavior;
use yii\behaviors\TimestampBehavior;

/**
 * This is the model class For table "investigation".
 *
 * @property string $id
 * @property string $created_by
 * @property string $updated_by
 * @property string $deleted_by
 * @property string $actid
 * @property string $relatedid
 * @property string $employee
 * @property string $vehicle
 * @property integer $created_at
 * @property integer $updated_at
 * @property integer $deleted_at
 * @property integer $jobno
 * @property string $status
 * @property string $padno
 * @property string $comname
 * @property string $comphone
 * @property string $type
 * @property string $overview
 * @property string $result
 */
class Investigationbe extends \common\models\Base
{
    public $dates = [];
	public $uniqueidentifiers = [];
    public $securefields = [];
   
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'investigation';
    }

    /**
     * @inheritdoc
     */
    public function rules(): array
    {
        return [
            [['id', 'created_by', 'updated_by', 'deleted_by', 'actid', 'relatedid', 'employee', 'vehicle', 'status', 'padno', 'comname', 'comphone', 'type', 'overview', 'result'], 'string'],
            [['created_at', 'updated_at', 'deleted_at', 'jobno'], 'integer'],
            [['id'], 'unique'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels(): array
    {
        return [
            'id' => 'ID',
            'created_by' => 'Created By',
            'updated_by' => 'Updated By',
            'deleted_by' => 'Deleted By',
            'actid' => 'Actid',
            'relatedid' => 'Relatedid',
            'employee' => 'Employee',
            'vehicle' => 'Vehicle',
            'created_at' => 'Created At',
            'updated_at' => 'Updated At',
            'deleted_at' => 'Deleted At',
            'jobno' => 'Jobno',
            'status' => 'Status',
            'padno' => 'Padno',
            'comname' => 'Comname',
            'comphone' => 'Comphone',
            'type' => 'Type',
            'overview' => 'Overview',
            'result' => 'Result',
        ];
    }
    public function getSteps() {
    if (Yii::$app->controller->action->id == 'create') {
			$tempid = Yii::$app->session->get('investstempid');
				return \modules\custom\models\Investigationstepsbe::find()->where(['relatedid' => "$tempid"])->all();
		} else {
			return $this->hasMany(\modules\custom\models\Investigationstepsbe::class, ['relatedid' => 'id']);	
		}
	}
	
}
