<?php

class StranasNewReportLogComments extends \Phalcon\Mvc\Model
{
    
    /**
     * Initialize method for model.
     */
    public function initialize()
    {
        $this->setSchema("jaga");
        $this->setSource("str_target_log_comment");
        $this->hasMany("id", "StranasNewCommentAttachment", "id_comment");
        $this->belongsTo("created_by", "UmUser", "um_id", ['alias' => 'commentator']);
    }

    public function getDetail($columns = null)
    {
        $result = parent::toArray($columns);
        $result['files'] = $this->StranasNewCommentAttachment;

        return $result;
    }
    
    public function toArray($columns = null)
    {
        $result = parent::toArray($columns);
        $result['commentator'] = empty($this->commentator) ? null : $this->commentator->toArraySimple();
        $result['files'] = $this->StranasNewCommentAttachment;

        return $result;
    }

    public function toDetail($columns = null)
    {
        $result = parent::toArray($columns);
        $result['files'] = $this->StranasNewCommentAttachment;

        return $result;
    }
}
