guillermo- path- staff-un-assign-ticket [skip ci]

This commit is contained in:
ivan 2016-10-14 16:12:54 -03:00
parent f94ac300bd
commit 5034ba71a3
2 changed files with 38 additions and 0 deletions

View File

@ -1,11 +1,13 @@
<?php
require_once 'staff/get.php';
require_once 'staff/assign-ticket.php';
require_once 'staff/un-assign-ticket.php';
$systemControllerGroup = new ControllerGroup();
$systemControllerGroup->setGroupPath('/staff');
$systemControllerGroup->addController(new GetStaffController);
$systemControllerGroup->addController(new AssignStaffController);
$systemControllerGroup->addController(new UnAssignStaffController);
$systemControllerGroup->finalize();

View File

@ -0,0 +1,36 @@
<?php
use Respect\Validation\Validator as DataValidator;
DataValidator::with('CustomValidations', true);
class UnAssignStaffController extends Controller {
const PATH = '/un-assign-ticket';
public function validations() {
return [
'permission' => 'staff_1',
'requestData' => [
'ticketNumber' => [
'validation' => DataValidator::validTicketNumber(),
'error' => ERRORS::INVALID_TICKET
]
]
];
}
public function handler() {
$ticketNumber = Controller::request('ticketNumber');
$user = Controller::getLoggedUser();
$ticket = Ticket::getByTicketNumber($ticketNumber);
if($ticket->owner->id == $user->id) {
$user->sharedTicketList->remove($ticket);
$user->store();
$ticket->owner = null;
$ticket->store();
Response::respondSuccess();
} else {
Response::respondError(ERRORS::NO_PERMISSION);
return;
}
}
}