示例#1
0
 /**
  * @return array
  */
 public function getAllEmployees()
 {
     $response = new StandardResponse();
     $queryString = "SELECT user.id, user.name, user.role, user.email, user.phone, user.created_at, user.updated_at " . "FROM \\App\\Entity\\User user WHERE user.role = 'employee'";
     $query = $this->em->createQuery($queryString);
     $results = $query->getArrayResult();
     if ($results) {
         $response->setSuccess(true);
         $response->setMessage('Here are the employees.');
         $response->setData($results);
     }
     return $response->getObjectVars();
 }
示例#2
0
 /**
  * @param int $id
  * @return null|object
  * @throws \Doctrine\ORM\ORMException
  * @throws \Doctrine\ORM\OptimisticLockException
  * @throws \Doctrine\ORM\TransactionRequiredException
  */
 public function get($id)
 {
     $response = new StandardResponse();
     $queryString = 'SELECT shift.id, shift.manager_id, shift.employee_id, shift.break, ' . 'shift.start_time, shift.end_time, shift.created_at, shift.updated_at FROM \\App\\Entity\\Shift shift ' . 'WHERE shift.id = :id';
     $shift = $this->em->createQuery($queryString)->setParameter('id', (int) $id)->getArrayResult();
     if ($shift) {
         if (isset($shift[0])) {
             $shift[0]['start_time'] = $shift[0]['start_time']->getTimestamp();
             $shift[0]['end_time'] = $shift[0]['end_time']->getTimestamp();
         }
         $response->setSuccess(true);
         $response->setMessage('Here is the shift.');
         $response->setData(isset($shift[0]) ? $shift[0] : []);
     }
     return $response->getObjectVars();
 }
 /**
  * @param int $id
  * @return StandardResponse
  */
 public function getUser($id)
 {
     $response = new StandardResponse();
     $response->setMessage('User not found');
     $queryString = 'SELECT user FROM \\App\\Entity\\User user WHERE user.id = :id';
     $user = $this->em->createQuery($queryString)->setParameter('id', (int) $id)->getArrayResult();
     if (isset($user[0])) {
         $response->setSuccess(true);
         $response->setMessage('Here is the user.');
         $response->setData($user[0]);
     }
     return $response->getObjectVars();
 }