<commit_before><?php

namespace Michaeljennings\Feed\Notifications;

use Michaeljennings\Feed\Contracts\Repository as RepositoryContracts;

class Repository implements RepositoryContracts
{
    /**
     * Create a new notification.
     *
     * @param array $notification
     * @return \Michaeljennings\Feed\Contracts\Notification
     */
    public function newNotification(array $notification)
    {
        return new Notification($notification);
    }

    /**
     * @param array $types
     * @param array $ids
     * @param null  $limit
     * @param null  $offset
     * @return mixed
     */
    public function getNotifications(array $types, array $ids, $limit = null, $offset = null)
    {
        $query = Notification::whereIn('notifiable_type', $types)
                             ->whereIn('notifiable_id', $ids)
                             ->where('read', false);

        if ($limit) {
            $query->limit($limit);
        }

        if ($offset) {
            $query->offset($offset);
        }

        return $query->get();
    }
}<commit_msg>Add read and unread methods to the notification repository<commit_after><?php

namespace Michaeljennings\Feed\Notifications;

use Carbon\Carbon;
use Michaeljennings\Feed\Contracts\Notification as NotificationContract;
use Michaeljennings\Feed\Contracts\Repository as RepositoryContract;

class Repository implements RepositoryContract
{
    /**
     * Create a new notification.
     *
     * @param array $notification
     * @return \Michaeljennings\Feed\Contracts\Notification
     */
    public function newNotification(array $notification)
    {
        return new Notification($notification);
    }

    /**
     * Get all of the unread notifications for the notifiable members.
     *
     * @param array $types
     * @param array $ids
     * @param null  $limit
     * @param null  $offset
     * @return mixed
     */
    public function getNotifications(array $types, array $ids, $limit = null, $offset = null)
    {
        $query = Notification::whereIn('notifiable_type', $types)
                             ->whereIn('notifiable_id', $ids)
                             ->where('read', false);

        if ($limit) {
            $query->limit($limit);
        }

        if ($offset) {
            $query->offset($offset);
        }

        return $query->get();
    }

    /**
     * Get all of the read notifications for the notifiable members.
     *
     * @param array $types
     * @param array $ids
     * @param null  $limit
     * @param null  $offset
     * @return mixed
     */
    public function getReadNotifications(array $types, array $ids, $limit = null, $offset = null)
    {
        $query = Notification::whereIn('notifiable_type', $types)
                             ->whereIn('notifiable_id', $ids)
                             ->where('read', true);

        if ($limit) {
            $query->limit($limit);
        }

        if ($offset) {
            $query->offset($offset);
        }

        return $query->get();
    }

    /**
     * Mark the notification as read.
     *
     * @param NotificationContract $notification
     * @return mixed
     */
    public function read(NotificationContract $notification)
    {
        $notification->read = true;
        $notification->read_at = new Carbon();

        return $notification->save();
    }

    /**
     * Mark the notification as unread.
     *
     * @param NotificationContract $notification
     * @return mixed
     */
    public function unread(NotificationContract $notification)
    {
        $notification->read = false;
        $notification->read_at = null;

        return $notification->save();
    }
}
{'fraction_non_alphanumeric': 0.11541587645624492, 'fraction_numerical': 0.0, 'mean_word_length': 2.0664451827242525, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2114829', 'n_tokens_mistral': 1006, 'n_tokens_neox': 976, 'n_words': 246}