|
@@ 303-312 (lines=10) @@
|
| 300 |
|
* @param Closure $filterScope |
| 301 |
|
* @return mixed |
| 302 |
|
*/ |
| 303 |
|
public function countNotRead($to_id, $entity, Closure $filterScope = null) |
| 304 |
|
{ |
| 305 |
|
$query = $this->notification->wherePolymorphic($to_id, $entity) |
| 306 |
|
->withNotRead() |
| 307 |
|
->select($this->db->raw('Count(*) as notRead')); |
| 308 |
|
|
| 309 |
|
$query = $this->applyFilter($filterScope, $query); |
| 310 |
|
|
| 311 |
|
return $query->count(); |
| 312 |
|
} |
| 313 |
|
|
| 314 |
|
/** |
| 315 |
|
* Get last notification of the current |
|
@@ 323-331 (lines=9) @@
|
| 320 |
|
* @param Closure $filterScope |
| 321 |
|
* @return mixed |
| 322 |
|
*/ |
| 323 |
|
public function getLastNotification($to_id, $entity, Closure $filterScope = null) |
| 324 |
|
{ |
| 325 |
|
$query = $this->notification->wherePolymorphic($to_id, $entity) |
| 326 |
|
->orderBy('created_at', 'DESC'); |
| 327 |
|
|
| 328 |
|
$query = $this->applyFilter($filterScope, $query); |
| 329 |
|
|
| 330 |
|
return $query->first(); |
| 331 |
|
} |
| 332 |
|
|
| 333 |
|
/** |
| 334 |
|
* Get last notification of the current |
|
@@ 343-353 (lines=11) @@
|
| 340 |
|
* @param Closure $filterScope |
| 341 |
|
* @return mixed |
| 342 |
|
*/ |
| 343 |
|
public function getLastNotificationByCategory($category, $to_id, $entity, Closure $filterScope = null) |
| 344 |
|
{ |
| 345 |
|
$query = $this->notification |
| 346 |
|
->wherePolymorphic($to_id, $entity) |
| 347 |
|
->byCategory($category) |
| 348 |
|
->orderBy('created_at', 'desc'); |
| 349 |
|
|
| 350 |
|
$query = $this->applyFilter($filterScope, $query); |
| 351 |
|
|
| 352 |
|
return $query->first(); |
| 353 |
|
} |
| 354 |
|
|
| 355 |
|
/** |
| 356 |
|
* Apply scope filters |