Guillermo - path / staff/get-all[skip ci]

This commit is contained in:
AntonyAntonio 2016-12-07 01:37:18 -03:00
parent b2547ce5f8
commit 1a3adfe418
4 changed files with 60 additions and 0 deletions

View File

@ -7,6 +7,8 @@ require_once 'staff/get-new-tickets.php';
require_once 'staff/get-all-tickets.php';
require_once 'staff/search-tickets.php';
require_once 'staff/add.php';
require_once 'staff/get-all.php';
require_once 'staff/delete.php';
$systemControllerGroup = new ControllerGroup();
$systemControllerGroup->setGroupPath('/staff');
@ -19,5 +21,7 @@ $systemControllerGroup->addController(new GetNewTicketsStaffController);
$systemControllerGroup->addController(new GetAllTicketsStaffController);
$systemControllerGroup->addController(new SearchTicketStaffController);
$systemControllerGroup->addController(new AddStaffController);
$systemControllerGroup->addController(new GetAllStaffController);
$systemControllerGroup->addController(new DeleteStaffController);
$systemControllerGroup->finalize();

View File

@ -0,0 +1,18 @@
<?php
use Respect\Validation\Validator as DataValidator;
class DeleteStaffController extends Controller {
const PATH = '/delete';
public function validations() {
return [
'permission' => 'staff_3',
'requestData' => []
];
}
public function handler (){
}
}

View File

@ -0,0 +1,27 @@
<?php
use Respect\Validation\Validator as DataValidator;
class GetAllStaffController extends Controller {
const PATH ='/get-all';
public function validations() {
return [
'permission' => 'staff_3',
'requestData' => []
];
}
public function handler() {
$staffs = Staff::getAll();
$staffArray = [];
foreach($staffs as $staff) {
$staffArray[] = $staff->toArray();
}
Response::respondSuccess($staffArray);
}
}

View File

@ -30,4 +30,15 @@ class Staff extends DataStore {
public static function getUser($value, $property = 'id') {
return parent::getDataStore($value, $property);
}
public function toArray() {
return [
'name'=> $this->name,
'email' => $this->email,
'password' => $this->password,
'profilePic' => $this->profilePic,
'level' => $this->level,
'departments' => $this->sharedDepartmentList->toArray(),
'tickets' => $this->sharedTicketList->toArray(),
];
}
}