|
@@ 311-320 (lines=10) @@
|
| 308 |
|
* @param Closure $filterScope |
| 309 |
|
* @return mixed |
| 310 |
|
*/ |
| 311 |
|
public function countNotRead($toId, $entity, Closure $filterScope = null) |
| 312 |
|
{ |
| 313 |
|
$query = $this->notification->wherePolymorphic($toId, $entity) |
| 314 |
|
->withNotRead() |
| 315 |
|
->select($this->db->raw('Count(*) as notRead')); |
| 316 |
|
|
| 317 |
|
$query = $this->applyFilter($filterScope, $query); |
| 318 |
|
|
| 319 |
|
return $query->count(); |
| 320 |
|
} |
| 321 |
|
|
| 322 |
|
/** |
| 323 |
|
* Get last notification of the current |
|
@@ 331-339 (lines=9) @@
|
| 328 |
|
* @param Closure $filterScope |
| 329 |
|
* @return mixed |
| 330 |
|
*/ |
| 331 |
|
public function getLastNotification($toId, $entity, Closure $filterScope = null) |
| 332 |
|
{ |
| 333 |
|
$query = $this->notification->wherePolymorphic($toId, $entity) |
| 334 |
|
->orderBy('created_at', 'DESC'); |
| 335 |
|
|
| 336 |
|
$query = $this->applyFilter($filterScope, $query); |
| 337 |
|
|
| 338 |
|
return $query->first(); |
| 339 |
|
} |
| 340 |
|
|
| 341 |
|
/** |
| 342 |
|
* Get last notification of the current |
|
@@ 351-361 (lines=11) @@
|
| 348 |
|
* @param Closure $filterScope |
| 349 |
|
* @return mixed |
| 350 |
|
*/ |
| 351 |
|
public function getLastNotificationByCategory($category, $toId, $entity, Closure $filterScope = null) |
| 352 |
|
{ |
| 353 |
|
$query = $this->notification |
| 354 |
|
->wherePolymorphic($toId, $entity) |
| 355 |
|
->byCategory($category) |
| 356 |
|
->orderBy('created_at', 'desc'); |
| 357 |
|
|
| 358 |
|
$query = $this->applyFilter($filterScope, $query); |
| 359 |
|
|
| 360 |
|
return $query->first(); |
| 361 |
|
} |
| 362 |
|
|
| 363 |
|
/** |
| 364 |
|
* Apply scope filters. |