<?php

class StranasTargetAnswerCommentWithAttachment extends \Phalcon\Mvc\Model
{

    /**
     * Initialize method for model.
     */
    public function initialize()
    {
        $this->setSchema("jaga");
        $this->setSource("stranas_survey_answer_comment");
        
        $this->hasOne("created_by", "UmUser", "um_id", ['alias' => 'verificator']);
        $this->hasMany("id", "StranasTargetCommentWithAttachment", "id_comment");
    }

    public function toArray($columns = null)
    {
        $result = parent::toArray($columns);
        $result['attachments'] = $this->StranasTargetCommentWithAttachment;
        $result['comment_by'] = empty($this->verificator) ? null : $this->verificator->toArraySimple();
        // $result['answer_by'] = $this->UmUser;
        // $result['comments'] = $this->StranasTargetAnswerCommentWithAttachment;

        return $result;
    }
    // public function getDetail()
    // {
    //     $result = $this->toArray();
    //     $result['verificator'] = empty($this->verificator) ? null : $this->verificator->toArraySimple();

    //     return $result;
    // }
}


