View file upload/src/addons/XenCentral/Feedback/Entity/Feedback.php

File size: 2.51Kb
<?php
/**
 * @package XenCentral Feedback System
 * @author DNF Technology
 * @copyright Drnoyan & Nalyan LDA, Portugal, EU
 * @license http://dnf.technology/terms/
 * @link http://customers.dnf.technology
 * @version 2.0.0 Beta 10
 * @revision 12
 */

namespace XenCentral\Feedback\Entity;

use XF\Mvc\Entity\Entity;
use XF\Mvc\Entity\Structure;


class Feedback extends Entity
{
    public static function getStructure(Structure $structure)
    {

        $structure->table = 'xf_xc_feedback_feedback';
        $structure->shortName = 'XenCentral\Feedback:Feedback';
        $structure->primaryKey = 'fb_id';
        $structure->contentType = 'feedback';
        $structure->columns = [
            'fb_id' => ['type' => self::UINT, 'autoIncrement' => true, 'nullable' => true],
            'foruserid' => ['type' => self::UINT, 'default'=> 0,
                'required' => 'true'
            ],
            'fromuserid' => ['type' => self::UINT, 'default'=> 0,
                'required' => 'true'
            ],
            'amount' => ['type' => self::INT, 'default'=> 0,
                'required' => 'true'
            ],
            'type' => ['type' => self::STR, 'default' => 'feedback',
                'allowedValues' => ['buy', 'sell', 'trade']
            ],
            'review' => ['type' => self::STR, 'maxLength' => 255],
            'dealurl' => ['type' => self::STR, 'maxLength' => 1000],
            'threadid' => ['type' => self::UINT, 'default' => 0, 'maxLength' => 11],
            'dateline' => ['type' => self::UINT, 'default' => \XF::$time],
            'ip_id' => ['type' => self::UINT, 'default' => 0, 'maxLength' => 10],
            'importid' => ['type' => self::STR, 'default' => 0],
            'has_reply' => ['type' => self::UINT, 'default' => 1, 'maxLength' =>1]];
        $structure->behaviors = [
            'XenCentral\Feedback:Feedback' =>   []];
        $structure->relations = [
            'User' => [
                'entity' => 'XF:User',
                'type' => self::TO_ONE,
                'conditions' => [
                    ['user_id', '=', '$foruserid'],
                ],
                'primary' => true
            ],
            'FbUser' => [
                'entity' => 'XenCentral\Feedback:FeedbackUser',
                'type' => self::TO_ONE,
                'conditions' => [
                    ['user_id', '=', '$foruserid'],

                ],
                'primary' => true
            ]
        ];

	    $structure->options = [
		    'saveip' => true
	    ];

        return $structure;
    }
}