@@ 235-260 (lines=26) @@ | ||
232 | * @param Closure|null $filterScope |
|
233 | * @return mixed |
|
234 | */ |
|
235 | public function getNotRead( |
|
236 | $toId, |
|
237 | $entity, |
|
238 | $limit = null, |
|
239 | $paginate = null, |
|
240 | $orderDate = 'desc', |
|
241 | Closure $filterScope = null |
|
242 | ) { |
|
243 | $query = $this->notification->with('body', 'from') |
|
244 | ->wherePolymorphic($toId, $entity) |
|
245 | ->withNotRead() |
|
246 | ->orderBy('read', 'ASC') |
|
247 | ->orderBy('created_at', $orderDate); |
|
248 | ||
249 | if ($limit && ! $paginate) { |
|
250 | $query->limit($limit); |
|
251 | } |
|
252 | ||
253 | $query = $this->applyFilter($filterScope, $query); |
|
254 | ||
255 | if (is_int(intval($paginate)) && $paginate) { |
|
256 | return $query->paginate($limit); |
|
257 | } |
|
258 | ||
259 | return $query->get(); |
|
260 | } |
|
261 | ||
262 | /** |
|
263 | * Retrieve all notifications, not read |
|
@@ 276-300 (lines=25) @@ | ||
273 | * @param Closure $filterScope |
|
274 | * @return mixed |
|
275 | */ |
|
276 | public function getAll( |
|
277 | $toId, |
|
278 | $entity, |
|
279 | $limit = null, |
|
280 | $paginate = null, |
|
281 | $orderDate = 'desc', |
|
282 | Closure $filterScope = null |
|
283 | ) { |
|
284 | $query = $this->notification->with('body', 'from') |
|
285 | ->wherePolymorphic($toId, $entity) |
|
286 | ->orderBy('read', 'ASC') |
|
287 | ->orderBy('created_at', $orderDate); |
|
288 | ||
289 | if ($limit && ! $paginate) { |
|
290 | $query->limit($limit); |
|
291 | } |
|
292 | ||
293 | $query = $this->applyFilter($filterScope, $query); |
|
294 | ||
295 | if (is_int(intval($paginate)) && $paginate) { |
|
296 | return $query->paginate($limit); |
|
297 | } |
|
298 | ||
299 | return $query->get(); |
|
300 | } |
|
301 | ||
302 | /** |
|
303 | * get number Notifications |
|
@@ 392-415 (lines=24) @@ | ||
389 | * @param Closure $filterScope |
|
390 | * @return mixed |
|
391 | */ |
|
392 | public function getStack( |
|
393 | $stackId, |
|
394 | $limit = null, |
|
395 | $paginate = null, |
|
396 | $orderDate = 'desc', |
|
397 | Closure $filterScope = null |
|
398 | ) { |
|
399 | $query = $this->notification->with('body', 'from', 'to') |
|
400 | ->byStack($stackId) |
|
401 | ->orderBy('read', 'ASC') |
|
402 | ->orderBy('created_at', $orderDate); |
|
403 | ||
404 | if ($limit && ! $paginate) { |
|
405 | $query->limit($limit); |
|
406 | } |
|
407 | ||
408 | $query = $this->applyFilter($filterScope, $query); |
|
409 | ||
410 | if (is_int(intval($paginate)) && $paginate) { |
|
411 | return $query->paginate($limit); |
|
412 | } |
|
413 | ||
414 | return $query->get(); |
|
415 | } |
|
416 | } |
|
417 |