/** * @inheritDoc * As an employee, I want to know how much I worked, by being able to get a summary of hours worked for each week. */ public function __invoke(array $input) { //make sure an employee with the given id exists if (false === parent::__invoke($input)) { return $this->payload->withStatus(PayloadInterface::INVALID); } $summary = $this->entityManager->getRepository('Spark\\Project\\Entity\\User\\Employee')->getHoursWorkedPerWeek($this->employee->getId()); return $this->payload->withStatus(PayloadInterface::OK)->withOutput(['employee_id' => $this->employee->getId(), 'hours_per_week' => $summary]); }
/** * @inheritDoc * As an employee, I want to know when I am working, by being able to see all of the shifts assigned to me. * and As an employee, I want to be able to contact my managers, by seeing manager contact information for my shifts. */ public function __invoke(array $input) { //make sure an employee with the given id exists if (false === parent::__invoke($input)) { return $this->payload->withStatus(PayloadInterface::INVALID); } $shifts = []; foreach ($this->employee->getShifts() as $shift) { $shifts[] = ['id' => $shift->getId(), 'start_time' => $shift->getStart_time()->format(constant("DateTime::{$this->date_format}")), 'end_time' => $shift->getEnd_time()->format(constant("DateTime::{$this->date_format}")), 'manager' => ['id' => $shift->getManager()->getId(), 'name' => $shift->getManager()->getName(), 'phone' => $shift->getManager()->getPhone(), 'email' => $shift->getManager()->getEmail()]]; } return $this->payload->withStatus(PayloadInterface::OK)->withOutput(['employee_id' => $this->employee->getId(), 'shifts' => $shifts]); }
/** * @inheritDoc * As an employee, I want to know who I am working with, by being able to see * the employees that are working during the same time period as me. */ public function __invoke(array $input) { //make sure an employee with the given id exists if (false === parent::__invoke($input)) { return $this->payload->withStatus(PayloadInterface::INVALID); } $results = $this->entityManager->getRepository('Spark\\Project\\Entity\\User\\Employee')->worksWith($this->employee->getId()); $shifts = []; foreach ($results as $shift) { $shifts[] = ['id' => $shift['id'], 'start_time' => $shift['start_time']->format(constant("DateTime::{$this->date_format}")), 'end_time' => $shift['end_time']->format(constant("DateTime::{$this->date_format}")), 'employee' => ['name' => $shift['name'], 'id' => $shift['employee_id']]]; } return $this->payload->withStatus(PayloadInterface::OK)->withOutput(['shifts' => $shifts]); }