/**
  * Retrive all notifications, not read
  * in first.
  * You can also limit the number of
  * Notifications if you don't, it will get all
  *
  * @param         $to_id
  * @param         $entity
  * @param  null   $limit
  * @param  bool   $paginate
  * @param  string $orderDate
  * @return mixed
  */
 public function getAll($to_id, $entity, $limit = null, $paginate = false, $orderDate = 'desc')
 {
     $result = $this->notification->with('body', 'from')->wherePolymorphic($to_id, $entity)->orderBy('read', 'ASC')->orderBy('created_at', $orderDate);
     // if the limit is set
     if (!is_null($limit)) {
         $result->limit($limit);
     }
     return $result->get();
 }
 /**
  * Retrive all notifications, not read
  * in first.
  * You can also limit the number of
  * Notifications if you don't, it will get all
  *
  * @param           $to_id
  * @param           $entity
  * @param  null     $limit
  * @param  int|null $paginate
  * @param  string   $orderDate
  * @param Closure   $filterScope
  * @return mixed
  */
 public function getAll($to_id, $entity, $limit = null, $paginate = null, $orderDate = 'desc', Closure $filterScope = null)
 {
     $query = $this->notification->with('body', 'from')->wherePolymorphic($to_id, $entity)->orderBy('read', 'ASC')->orderBy('created_at', $orderDate);
     $query = $this->applyFilter($filterScope, $query);
     if (is_int(intval($paginate)) && $paginate) {
         return $query->paginate($limit);
     }
     return $query->get();
 }
 /**
  * Retrive all notifications, in a stack.
  * You can also limit the number of
  * Notifications if you don't, it will get all.
  *
  * @param           $stackId
  * @param  null     $limit
  * @param  int|null $paginate
  * @param  string   $orderDate
  * @param Closure   $filterScope
  * @return mixed
  */
 public function getStack($stackId, $limit = null, $paginate = null, $orderDate = 'desc', Closure $filterScope = null)
 {
     $query = $this->notification->with('body', 'from', 'to')->byStack($stackId)->orderBy('read', 'ASC')->orderBy('created_at', $orderDate);
     if ($limit && !$paginate) {
         $query->limit($limit);
     }
     $query = $this->applyFilter($filterScope, $query);
     if (is_int(intval($paginate)) && $paginate) {
         return $query->paginate($limit);
     }
     return $query->get();
 }