<?php

namespace Tricks\LaravelTools\Traits;

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;

/**
 * @template TModel of Model
 */
trait HasOrderedScope
{
    /**
     * @param  Builder<TModel>  $query
     * @return Builder<TModel>
     */
    public function scopeOrdered(Builder $query, string $column, string $direction = 'desc'): Builder
    {
        return $query->orderBy($column, $direction);
    }
}
