2016-12-07 05:37:18 +01:00
|
|
|
<?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) {
|
2016-12-08 07:21:37 +01:00
|
|
|
$assignedTickets = 0;
|
|
|
|
$closedTickets = 0;
|
|
|
|
|
|
|
|
foreach ($staff->sharedTicketList as $ticket) {
|
|
|
|
if($ticket->closed) $closedTickets++;
|
|
|
|
else $assignedTickets++;
|
|
|
|
}
|
|
|
|
|
|
|
|
$staffArray[] = [
|
2016-12-08 18:30:19 +01:00
|
|
|
'id' => $staff->id,
|
2016-12-08 07:21:37 +01:00
|
|
|
'name' => $staff->name,
|
|
|
|
'email' => $staff->email,
|
|
|
|
'profilePic' => $staff->profilePic,
|
|
|
|
'level' => $staff->level,
|
|
|
|
'departments' => $staff->sharedDepartmentList->toArray(),
|
|
|
|
'assignedTickets' => $assignedTickets,
|
|
|
|
'closedTickets' => $closedTickets,
|
2016-12-08 21:39:47 +01:00
|
|
|
'lastLogin' => $staff->lastLogin
|
2016-12-08 07:21:37 +01:00
|
|
|
];
|
2016-12-07 05:37:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Response::respondSuccess($staffArray);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|