Get certain post by its ID or throw exception if nothing found.

@param Client $client
@param int    $id

@throws PostNotFoundException if post not found

@return Post
517388
public static function byId(
        Client $client,
        int $id
    ): self {
        $posts = self::search($client, ['id:' . $id], 1, 1);

        if (count($posts) === 0) {
            throw new PostNotFoundException(sprintf(
                'Post with ID %d not found',
                $id
            ));
        }

        return $posts[0];
    }
199329
public function getAthlete($id = null)
    {
        try {
            return $this->service->getAthlete($id);
        } catch (ServiceException $e) {
            throw new ClientException('[SERVICE] ' . $e->getMessage());
        }
    }
270852
public function get($id)
    {
        if (! $this->has($id)) {
            throw new NotFoundException(
                sprintf('Identifier %s is not defined in container', $id)
            );
        }

        $entry = $this->container[$id]->instance();

        if (is_callable($entry)) {
            return $entry($this);
        }

        return $entry;
    }
1342563
public function getDeepLinkOrder(string $id, Request $request, Context $context): JsonResponse
    {
        $deepLinkCode = (string) $request->query->get('accessCode');

        if ($id === '' || \strlen($deepLinkCode) !== 32) {
            throw new OrderNotFoundException($id);
        }

        $criteria = new Criteria();
        $criteria->addAssociation('addresses');
        $criteria->addFilter(new EqualsFilter('id', $id));
        $criteria->addFilter(new EqualsFilter('deepLinkCode', $deepLinkCode));

        $orders = $this->orderRepository->search($criteria, $context);
        if ($orders->getTotal() === 0) {
            throw new OrderNotFoundException($id);
        }

        return new JsonResponse($this->serialize($orders->first()));
    }
598888
public function find($id)
    {
        if (trim($id) == "") {
            throw new Exception\NotFound('dispute with id "' . $id . '" not found');
        }

        try {
            $path = $this->_config->merchantPath() . '/disputes/' . $id;
            $response = $this->_http->get($path);
            return Dispute::factory($response['dispute']);
        } catch (Exception\NotFound $e) {
            throw new Exception\NotFound('dispute with id "' . $id . '" not found');
        }
    }
400189
public function getAction(Request $request, $id)
    {
        $locale = $this->getProductLocaleManager()->retrieveLocale($this->getUser(), $request->get('locale'));
        try {
            $attribute = $this->getManager()->findByIdAndLocale($id, $locale);
            $view = $this->view($attribute, 200);
        } catch (AttributeNotFoundException $exc) {
            $exception = new EntityNotFoundException($exc->getEntityName(), $exc->getId());
            $view = $this->view($exception->toArray(), 404);
        }

        return $this->handleView($view);
    }
418557
protected function findModel($id)
    {
        $user = User::findOne($id);
        if ($user === null) {
            throw new NotFoundHttpException('The requested page does not exist');
        }
        return $user;
    }
1291855
public function get($id)
    {
        $entity = $this->repository->find($id);

        if (!$entity) {
            throw new RestNotFoundException();
        }

        return $entity;
    }
372591
public function getID($ID)
    {
        if($this->hasID($ID)) {
            return $this->offsetGet($this->safeOffset($ID));
        } else {
            throw new CollectionIDNotFoundException('ID "' . $ID . '" does not exist in collection');
        }
    }
41180
public function getStreamsRoute($id)
    {
        try {
            return $this->service->getStreamsRoute($id);
        } catch (ServiceException $e) {
            throw new ClientException('[SERVICE] ' . $e->getMessage());
        }
    }
564227
protected function findModel($id)
    {
        if (($model = \yongtiger\admin\models\Log::findOne($id)) !== null) {
            return $model;
        } else {
            throw new NotFoundHttpException('The requested page does not exist.');
        }
    }
397837
private function findNode($id)
    {
        $node = $this->get('clastic.node_manager')
            ->loadNode($id);

        if (!$node) {
            throw new NotFoundHttpException();
        }

        return $node;
    }
216864
public static function findOrFail($id, array $params = [])
    {
        $instance = new static([], static::getParentID());

        // Make request
        if (!is_null($result = $instance->request($instance->getEndpoint(), 'find', [$id, $params]))) {
            return $result;
        }

        // Not found
        throw new NotFoundException;
    }
751176
public function getOrFail($id)
    {
        if ($model = $this->get($id)) {
            return $model;
        }

        throw (new NotFoundException("No results for id $id"))->setModel(get_class($this->model));
    }
1014621
protected function findModel($id)
    {
        $class = $this->userClassName;
        if (($user = $class::findIdentity($id)) !== null) {
            return new Assignment($id, $user);
        } else {
            throw new NotFoundHttpException('The requested page does not exist.');
        }
    }
1352414
public function findById($id)
	{
		$model = $this->createModel();

		$user = $model->where('id', '=', $id)->find();

		if ( ! $user->loaded() )
		{
			throw new UserNotFoundException("A user could not be found with ID [$id].");
		}

		return $user;
	}
52884
public function getClientDetails($client_id)
    {
        $result = $this->collection('client_table')->findOne(array('client_id' => $client_id));
        return is_null($result) ? false : $result;
    }