opensupports/server/controllers/system/add-department.php

51 lines
1.0 KiB
PHP
Raw Normal View History

<?php
use Respect\Validation\Validator as DataValidator;
2017-04-18 02:09:16 +02:00
/**
* @api {post} /system/add-department Add department
* @apiVersion 4.1.0
2017-04-18 02:09:16 +02:00
*
* @apiName Add department
*
* @apiGroup System
2017-04-18 02:09:16 +02:00
*
* @apiDescription This path create a new department.
*
* @apiPermission staff3
2017-04-18 02:09:16 +02:00
*
2017-04-21 08:09:24 +02:00
* @apiParam {String} name Name of the new department.
2017-04-18 02:09:16 +02:00
*
2017-04-21 08:09:24 +02:00
* @apiUse NO_PERMISSION
2017-04-18 02:09:16 +02:00
*
2017-04-22 03:33:17 +02:00
* @apiSuccess {Object} data Empty object
2017-04-18 02:09:16 +02:00
*
*/
class AddDepartmentController extends Controller {
const PATH = '/add-department';
const METHOD = 'POST';
public function validations() {
return [
'permission' => 'staff_3',
2018-01-13 03:08:07 +01:00
'requestData' => []
];
}
public function handler() {
2018-01-16 05:26:13 +01:00
$name = htmlentities(Controller::request('name'));
2018-01-13 03:08:07 +01:00
$departmentInstance = new Department();
2018-01-13 03:08:07 +01:00
$departmentInstance->setProperties([
'name' => $name,
]);
$departmentInstance->store();
Log::createLog('ADD_DEPARTMENT', $name);
Response::respondSuccess();
}
2018-01-13 03:08:07 +01:00
}