/** * Get notifications not read * of the entity given * * @param $to_id * @param $limit * @param int|null $paginate * @param string $orderDate * @param Closure $filterScope * @return mixed */ public function getNotRead($to_id, $limit = null, $paginate = null, $orderDate = 'desc', Closure $filterScope = null) { $notifications = $this->notifynderRepo->getNotRead($to_id, $this->entity, $limit, $paginate, $orderDate, $filterScope); if (is_int(intval($paginate)) && $paginate) { return new LengthAwarePaginator($notifications->parse(), $notifications->total(), $limit, $paginate, ['path' => LengthAwarePaginator::resolveCurrentPath()]); } return $notifications->parse(); }
/** * Get notifications not read * of the entity given * * @param $to_id * @param $limit * @param int|null $paginate * @param string $orderDate * @return mixed */ public function getNotRead($to_id, $limit = null, $paginate = null, $orderDate = 'desc') { $notifications = $this->notifynderRepo->getNotRead($to_id, $this->entity, $limit, $paginate, $orderDate); if (is_int(intval($paginate)) && !is_null($paginate)) { return new Paginator($notifications->parse(), $limit, $paginate, ['path' => Paginator::resolveCurrentPath()]); } return $notifications->parse(); }
/** * Get notifications not read * of the entity given * * @param $to_id * @param $limit * @param $paginate * @param string $orderDate * @return mixed */ public function getNotRead($to_id, $limit = null, $paginate = false, $orderDate = 'desc') { $notifications = $this->notifynderRepo->getNotRead($to_id, $this->entity, $limit, $paginate, $orderDate); if ($paginate) { return (new Paginator($notifications->parse()->toArray(), $limit))->toArray(); } return $notifications->parse(); }
/** * Get notifications not read * of the entity given. * * @param $toId * @param $limit * @param int|null $paginate * @param string $orderDate * @param Closure $filterScope * @return mixed */ public function getNotRead($toId, $limit = null, $paginate = null, $orderDate = 'desc', Closure $filterScope = null) { $queryLimit = $limit; if ($this->isPaginated($paginate)) { $queryLimit = null; } $notifications = $this->notifynderRepo->getNotRead($toId, $this->entity, $queryLimit, null, $orderDate, $filterScope); return $this->getPaginatedIfNeeded($notifications, $limit, $paginate); }
/** @test */ public function it_get_not_read_notification(NotificationDB $notificationRepo, NotifynderCollection $collection) { $entity_id = 1; $limit = 10; $paginate = null; $notificationRepo->getNotRead($entity_id, null, $limit, $paginate, 'desc', null)->shouldBeCalled()->willReturn($collection); $collection->parse()->shouldBeCalled()->willReturn([]); $this->getNotRead($entity_id, $limit, $paginate, 'desc')->shouldReturn([]); }