Fenos\Notifynder\Notifications\NotificationRepository::countNotRead PHP Method

countNotRead() public method

get number Notifications not read.
public countNotRead ( $toId, $entity, Closur\Closure $filterScope = null ) : mixed
$toId
$entity
$filterScope Closur\Closure
return mixed
    public function countNotRead($toId, $entity, Closure $filterScope = null)
    {
        $query = $this->notification->wherePolymorphic($toId, $entity)->withNotRead()->select($this->db->raw('Count(*) as notRead'));
        $query = $this->applyFilter($filterScope, $query);
        return $query->count();
    }

Usage Example

 /** @test */
 function it_count_notification_not_read()
 {
     $this->createMultipleNotifications();
     $countNotRead = $this->notificationRepo->countNotRead($this->to['id'], $this->to['type']);
     $this->assertEquals($this->multiNotificationsNumber, $countNotRead);
 }