guillermo- path- staff-un-assign-ticket [skip ci]
This commit is contained in:
parent
f94ac300bd
commit
5034ba71a3
|
@ -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();
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue