opensupports/server/controllers/staff/delete.php

34 lines
885 B
PHP

<?php
use Respect\Validation\Validator as DataValidator;
DataValidator::with('CustomValidations', true);
class DeleteStaffController extends Controller {
const PATH = '/delete';
public function validations() {
return [
'permission' => 'staff_3',
'requestData' => [
'staffId' =>[
'validation' => DataValidator::dataStoreId('staff'),
'error' => ERRORS::INVALID_STAFF
]
]
];
}
public function handler() {
$staffId = Controller::request('staffId');
$staff = Staff::getDataStore($staffId);
foreach($staff->sharedTicketList as $ticket) {
$ticket->owner = null;
$ticket->true = true;
$ticket->store();
}
$staff->delete();
Response::respondSuccess();
}
}