2016-08-04 05:59:04 +02:00
|
|
|
<?php
|
2016-08-20 23:06:41 +02:00
|
|
|
use RedBeanPHP\Facade as RedBean;
|
2016-08-04 05:59:04 +02:00
|
|
|
|
2017-04-21 05:34:20 +02:00
|
|
|
/**
|
|
|
|
* @api {OBJECT} Department Department
|
2018-09-20 22:19:47 +02:00
|
|
|
* @apiVersion 4.3.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
|
|
|
*/
|
|
|
|
|
2016-08-04 05:59:04 +02:00
|
|
|
class Department extends DataStore {
|
|
|
|
const TABLE = 'department';
|
|
|
|
|
2016-08-05 01:21:51 +02:00
|
|
|
public static function getProps() {
|
2016-08-04 05:59:04 +02:00
|
|
|
return [
|
|
|
|
'name',
|
2016-12-10 22:55:12 +01:00
|
|
|
'sharedTicketList',
|
|
|
|
'owners'
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getDefaultProps() {
|
|
|
|
return [
|
|
|
|
'owners' => 0
|
2016-08-04 05:59:04 +02:00
|
|
|
];
|
|
|
|
}
|
2016-08-20 23:06:41 +02:00
|
|
|
|
|
|
|
public static function getDepartmentNames() {
|
2016-10-03 21:44:41 +02:00
|
|
|
$departmentsList = RedBean::findAll(Department::TABLE);
|
2016-08-20 23:06:41 +02:00
|
|
|
$departmentsNameList = [];
|
2016-10-03 21:44:41 +02:00
|
|
|
|
|
|
|
foreach($departmentsList as $department) {
|
2016-11-21 03:01:38 +01:00
|
|
|
$departmentsNameList[] = [
|
|
|
|
'id' => $department->id,
|
2016-12-10 22:55:12 +01:00
|
|
|
'name' => $department->name,
|
|
|
|
'owners' => $department->owners
|
2016-11-21 03:01:38 +01:00
|
|
|
];
|
2016-08-20 23:06:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return $departmentsNameList;
|
|
|
|
}
|
2016-12-08 07:21:37 +01:00
|
|
|
public function toArray() {
|
|
|
|
return [
|
|
|
|
'id' => $this->id,
|
2016-12-10 22:55:12 +01:00
|
|
|
'name' => $this->name,
|
|
|
|
'owners' => $this->owners
|
2016-12-08 07:21:37 +01:00
|
|
|
];
|
|
|
|
}
|
2016-08-04 05:59:04 +02:00
|
|
|
}
|