opensupports/server/models/Department.php

51 lines
1.3 KiB
PHP
Raw Normal View History

<?php
use RedBeanPHP\Facade as RedBean;
2017-04-21 05:34:20 +02:00
/**
* @api {OBJECT} Department Department
2017-05-11 21:37:03 +02:00
* @apiVersion 4.0.0
2017-04-21 05:34:20 +02:00
* @apiGroup Data Structures
2017-05-11 21:37:03 +02:00
* @apiParam {Number} id Id of the department.
* @apiParam {String} name Name of the department.
* @apiParam {[Staff](#api-Data_Structures-ObjectStaff)[]} owners List of owners of the department.
2017-04-21 05:34:20 +02:00
*/
class Department extends DataStore {
const TABLE = 'department';
public static function getProps() {
return [
'name',
'sharedTicketList',
'owners'
];
}
public function getDefaultProps() {
return [
'owners' => 0
];
}
public static function getDepartmentNames() {
$departmentsList = RedBean::findAll(Department::TABLE);
$departmentsNameList = [];
foreach($departmentsList as $department) {
2016-11-21 03:01:38 +01:00
$departmentsNameList[] = [
'id' => $department->id,
'name' => $department->name,
'owners' => $department->owners
2016-11-21 03:01:38 +01:00
];
}
return $departmentsNameList;
}
2016-12-08 07:21:37 +01:00
public function toArray() {
return [
'id' => $this->id,
'name' => $this->name,
'owners' => $this->owners
2016-12-08 07:21:37 +01:00
];
}
}