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