<?php

namespace modules\cors\models;


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

/**
 * This is the model class For table "vehicleservicehistory".
 *
 * @property string $id
 * @property integer $created_at
 * @property integer $updated_at
 * @property string $created_by
 * @property string $updated_by
 * @property string $deleted_by
 * @property integer $deleted_at
 * @property integer $deleted
 * @property string $actid
 * @property string $status
 * @property string $padno
 * @property integer $jobno
 * @property string $relatedid
 * @property string $description
 * @property string $warnings
 * @property string $furtheractions
 * @property integer $mileage
 * @property integer $date
 */
class Vehicleservicehistorybe extends \common\models\Base {
	
    public $dates = ['created_at', 'updated_at', 'deleted_at', 'date'];
	public $securefields = [];
	public $uniqueidentifiers = ['actid', 'relatedid'];
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'vehicleservicehistory';
    }

    /**
     * @inheritdoc
     */
    public function rules(): array
    {
        return [
            [['id', 'created_by', 'updated_by', 'deleted_by', 'actid', 'status', 'padno', 'relatedid', 'description', 'warnings', 'furtheractions', 'garage', 'type', 'paidby','invoiceno'], 'string'],
            [['deleted', 'jobno', 'mileage'], 'integer'],
            [['created_at', 'updated_at', 'deleted_at',], 'safe'],
            [['cost'], 'number'],
            [['status'], 'default', 'value' => 'Active'],
            [['date'], 'safe'],
            [['id'], 'unique'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels(): array {
        return [
            'id' => 'ID',
            'created_at' => 'Created At',
            'updated_at' => 'Updated At',
            'created_by' => 'Created By',
            'updated_by' => 'Updated By',
            'deleted_by' => 'Deleted By',
            'deleted_at' => 'Deleted At',
            'deleted' => 'Deleted',
            'actid' => 'Actid',
            'status' => 'Status',
            'padno' => 'Padno',
            'jobno' => 'Jobno',
            'relatedid' => 'Relatedid',
            'description' => 'Description',
            'warnings' => 'Warnings',
            'furtheractions' => 'Furtheractions',
            'mileage' => 'Mileage',
            'date' => 'Date',
        ];
    }
    public function getFiles() {
		return $this->hasMany(\backend\models\Uploadsbe::class, ['relatedid' => 'id']);
	}
	
    public function getVehicle() {
    	return $this->hasOne(\modules\cors\models\Vehiclebe::class, ['id' => 'relatedid']);
    }
}
