Your IP : 216.73.216.124


Current Path : /var/www/html/chatbot/backend/models/
Upload File :
Current File : /var/www/html/chatbot/backend/models/Attachment.php

<?php

namespace backend\models;

use Yii;
use common\models\Dermaga;

/**
 * This is the model class for table "doc_attach".
 *
 * @property integer $id
 * @property string $doc_title
 * @property string $file_name
 * @property string $file_name_sys
 * @property string $remarks
 * @property string $doctype
 * @property string $created_date
 * @property string $created_by
 * @property string $created_at
 * @property string $updated_by
 * @property string $updated_at
 *
 * @property OstGalMedia[] $ostGalMedia
 */
class Attachment extends Dermaga {

    public $file;
    public $file2;

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

    /**
     * @inheritdoc
     */
    public function rules() {
        return [
            [['created_date', 'created_at', 'updated_at'], 'safe'],
            [['doc_title', 'file_name', 'file_name_sys', 'remarks'], 'string', 'max' => 100],
            [['doctype'], 'string', 'max' => 50],
            [['created_by', 'updated_by'], 'string', 'max' => 50],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels() {
        return [
            'id' => Yii::t('app','ID'),
            'doc_title' =>  Yii::t('app','Document Title'),
            'file_name' =>  Yii::t('app','File Name'),
            'file_name_sys' =>  Yii::t('app','File Name Sys'),
            'remarks' =>  Yii::t('app','Remarks'),
            'doctype' =>  Yii::t('app','Document Type'),
            'created_date' =>  Yii::t('app','Created Date'),
            'created_by' =>  Yii::t('app','Created By'),
            'created_at' =>  Yii::t('app','Created At'),
            'updated_by' =>  Yii::t('app','Updated By'),
            'updated_at' =>  Yii::t('app','Updated Date'),
        ];
    }

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

    public function getOstGalMedia() {
        return $this->hasMany(OstGalMedia::className(), ['doc_attach_id' => 'id']);
    }

    public function upload() {
        if ($this->validate()) {
            $this->imageFile->saveAs('uploads/' . $this->imageFile->baseName . '.' . $this->imageFile->extension);
            return true;
        } else {
            return false;
        }
    }
    
    public function getDoctypes() {
        return $this->hasOne(Ref::className(), ['code' => 'doctype'])->andWhere(['cat' => 'ATTACHTYP']);
    }

}