<commit_before><?php

namespace TypiCMS\Modules\Events\Repositories;

use Illuminate\Database\Eloquent\Collection;
use Illuminate\Pagination\Paginator;
use TypiCMS\Modules\Core\Repositories\EloquentRepository;
use TypiCMS\Modules\Events\Models\Event;

class EloquentEvent extends EloquentRepository
{
    protected $repositoryId = 'events';

    protected $model = Event::class;

    /**
     * Get incomings events.
     *
     * @param int $number number of items to take
     *
     * @return Collection
     */
    public function upcoming($number = null)
    {
        return $this->published()->executeCallback(static::class, __FUNCTION__, func_get_args(), function () use ($number) {
            $query = $this->prepareQuery($this->createModel())
                ->where('end_date', '>=', date('Y-m-d'))
                ->orderBy('start_date');
            if ($number) {
                $query->take($number);
            }

            return $query->get();
        });
    }

    public function paginateUpcomingEvents($perPage = null, $attributes = ['*'], $pageName = 'page', $page = null)
    {
        $page = $page ?: Paginator::resolveCurrentPage($pageName);
        if (!request('preview')) {
            $this->published();
        }

        return $this->executeCallback(static::class, __FUNCTION__, array_merge(func_get_args(), compact('page')), function () use ($perPage, $attributes, $pageName, $page) {
            return $this->prepareQuery($this->createModel())
                ->order()
                ->where('end_date', '>=', date('Y-m-d'))
                ->paginate($perPage, $attributes, $pageName, $page);
        });
    }

    public function paginatePastEvents($perPage = null, $attributes = ['*'], $pageName = 'page', $page = null)
    {
        $page = $page ?: Paginator::resolveCurrentPage($pageName);
        if (!request('preview')) {
            $this->published();
        }

        return $this->executeCallback(static::class, __FUNCTION__, array_merge(func_get_args(), compact('page')), function () use ($perPage, $attributes, $pageName, $page) {
            return $this->prepareQuery($this->createModel())
                ->order()
                ->where('end_date', '<', date('Y-m-d'))
                ->paginate($perPage, $attributes, $pageName, $page);
        });
    }

    public function adjacent($direction, $model, $category_id = null, array $with = [], $all = false)<commit_msg>events order by<commit_after><?php

namespace TypiCMS\Modules\Events\Repositories;

use Illuminate\Database\Eloquent\Collection;
use Illuminate\Pagination\Paginator;
use TypiCMS\Modules\Core\Repositories\EloquentRepository;
use TypiCMS\Modules\Events\Models\Event;

class EloquentEvent extends EloquentRepository
{
    protected $repositoryId = 'events';

    protected $model = Event::class;

    /**
     * Get incomings events.
     *
     * @param int $number number of items to take
     *
     * @return Collection
     */
    public function upcoming($number = null)
    {
        return $this->published()->executeCallback(static::class, __FUNCTION__, func_get_args(), function () use ($number) {
            $query = $this->prepareQuery($this->createModel())
                ->where('end_date', '>=', date('Y-m-d'))
                ->orderBy('start_date');
            if ($number) {
                $query->take($number);
            }

            return $query->get();
        });
    }

    public function paginateUpcomingEvents($perPage = null, $attributes = ['*'], $pageName = 'page', $page = null)
    {
        $page = $page ?: Paginator::resolveCurrentPage($pageName);
        if (!request('preview')) {
            $this->published();
        }

        return $this->executeCallback(static::class, __FUNCTION__, array_merge(func_get_args(), compact('page')), function () use ($perPage, $attributes, $pageName, $page) {
            return $this->prepareQuery($this->createModel())
                ->orderBy('start_date')
                ->where('end_date', '>=', date('Y-m-d'))
                ->paginate($perPage, $attributes, $pageName, $page);
        });
    }

    public function paginatePastEvents($perPage = null, $attributes = ['*'], $pageName = 'page', $page = null)
    {
        $page = $page ?: Paginator::resolveCurrentPage($pageName);
        if (!request('preview')) {
            $this->published();
        }

        return $this->executeCallback(static::class, __FUNCTION__, array_merge(func_get_args(), compact('page')), function () use ($perPage, $attributes, $pageName, $page) {
            return $this->prepareQuery($this->createModel())
                ->order()
                ->where('end_date', '<', date('Y-m-d'))
                ->paginate($perPage, $attributes, $pageName, $page);
        });
    }

    public function adjacent($direction, $model, $category_id = null, array $with = [], $all = false)
{'fraction_non_alphanumeric': 0.1643499591169256, 'fraction_numerical': 0.0, 'mean_word_length': 2.67618332081142, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 51, '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': '108967', 'n_tokens_mistral': 1416, 'n_tokens_neox': 1382, 'n_words': 271}