<?php

class KorsupgahAnswerAttachment extends \Phalcon\Mvc\Model
{
    const TIPE_JAWABAN = 0;
    const TIPE_VERIFIKASI = 1;
    const TIPE_VERIFIKASI_QA = 2;
    const TIPE_VERIFIKASI_PIC = 3;

    const KEYS = [
        'attachments',
        'attachments_verification',
        'attachments_verification_qa',
        'attachments_verification_pic'
    ];

    public function initialize()
    {
        $this->setSchema('jaga');
        $this->setSource('korsupgah_answer_attachment');
        $this->belongsTo('id_answer', 'KorsupgahAnswer', 'id');
        $this->belongsTo("id_attachment", "Attachments", "id");
    }

    public function getDetail()
    {
        return $this->attachments->toArray(['uuid', 'filename', 'keterangan', 'tipe', 'created_at', 'deleted_at']);
    }

    public static function getSubfolder($tahun, $idSurvey) {
        return "korsupgah" . DIRECTORY_SEPARATOR . $tahun . DIRECTORY_SEPARATOR . $idSurvey;
    }
}
