'staff_3', 'requestData' => [ 'departmentId' => [ 'validation' => DataValidator::dataStoreId('department'), 'error' => ERRORS::INVALID_DEPARTMENT ], 'name' => [ 'validation' => DataValidator::notBlank()->length(1, 200), 'error' => ERRORS::INVALID_NAME ], ] ]; } public function handler() { $newName = Controller::request('name'); $departmentId = Controller::request('departmentId'); $private = Controller::request('private'); $departmentInstance = Department::getDataStore($departmentId); if($private && $departmentId == Setting::getSetting('default-department-id')->getValue()){ throw new RequestException(ERRORS::DEFAULT_DEPARTMENT_CAN_NOT_BE_PRIVATE); } if($private && Ticket::count(' author_id IS NOT NULL AND department_id = ? ', [$departmentId])) { throw new RequestException(ERRORS::DEPARTMENT_PRIVATE_TICKETS); } if($newName) $departmentInstance->name = $newName; $departmentInstance->private = $private ? 1 : 0; $departmentInstance->store(); Log::createLog('EDIT_DEPARTMENT', $departmentInstance->name); Response::respondSuccess(); } }