/** * Search the database for a User with the give id * * @param $id * @return User || NotFound */ public function fetchEntity($id) { try { $entity = $this->gateway->findByPk($id); if (!$entity) { return $this->payload->notFound(['id' => $id]); } return $this->payload->found([$this->entityName => $entity]); } catch (\Exception $e) { return $this->payload->error(['exception' => $e, 'id' => $id]); } }