<?php

declare(strict_types=1);

namespace App\Repositories\Eloquent\Criteria;

use Illuminate\Database\Eloquent\Builder;
use Prettus\Repository\Contracts\CriteriaInterface;
use Prettus\Repository\Contracts\RepositoryInterface;

/**
 * Class OrderByUpdatedAtAscCriteria
 *
 * @package App\Repositories\Eloquent\Criteria
 */
final class OrderByUpdatedAtAscCriteria implements CriteriaInterface
{
    /**
     * @param \Illuminate\Database\Eloquent\Builder             $model
     * @param \Prettus\Repository\Contracts\RepositoryInterface $repository
     *
     * @return \Illuminate\Database\Eloquent\Builder
     */
    public function apply($model, RepositoryInterface $repository): Builder
    {
        return $model->orderBy('updated_at');
    }
}
