opensupports/server/models/Topic.php

44 lines
1.1 KiB
PHP
Raw Normal View History

<?php
2017-04-21 08:09:24 +02:00
/**
* @api {OBJECT} Topic Topic
2019-03-06 16:47:24 +01:00
* @apiVersion 4.4.0
2017-04-21 08:09:24 +02:00
* @apiGroup Data Structures
* @apiParam {Number} id Id of the topic.
* @apiParam {String} name Name of the topic.
* @apiParam {String} icon Icon of the topic.
* @apiParam {String} iconColor Icon's color of the topic.
2018-11-08 18:51:04 +01:00
* @apiParam {Boolean} private Indicates if this event is not shown to users.
2017-04-22 03:33:17 +02:00
* @apiParam {[Article](#api-Data_Structures-ObjectArticle)[]} articles Articles of the Topic.
2017-04-21 08:09:24 +02:00
*/
class Topic extends DataStore {
const TABLE = 'topic';
public static function getProps() {
return [
'name',
'icon',
'iconColor',
2018-11-08 18:51:04 +01:00
'ownArticleList',
'private'
];
}
2016-11-23 02:27:05 +01:00
public function toArray() {
$articlesArray = [];
foreach($this->ownArticleList as $article) {
$articlesArray[] = $article->toArray();
}
return [
'id' => $this->id,
2016-11-23 02:27:05 +01:00
'name' => $this->name,
'icon' => $this->icon,
'iconColor' => $this->iconColor,
2018-11-08 18:51:04 +01:00
'private' => $this->private,
2016-11-23 02:27:05 +01:00
'articles' => $articlesArray
];
}
2018-11-08 18:51:04 +01:00
}