public function scopeWherePolymorphic($query, $toId, $type) { if (!$type or config('notifynder.polymorphic') === false) { return $query->where('to_id', $toId); } return $query->where('to_id', $toId)->where('to_type', $type); }
/** * Delete All notifications about the * current user * * @param $to_id int * @param $entity * @return Bool */ public function deleteAll($to_id, $entity) { $query = $this->db->table($this->notification->getTable()); return $this->notification->scopeWherePolymorphic($query, $to_id, $entity)->delete(); }