<?php

namespace App\Traits;

use Illuminate\Database\Eloquent\Builder;

trait OrderByIdDesc
{

    /**
     * Notes: 初始化trait，自动在模型中，注入作用域
     * @Author: <C.Jason>
     * @Date  : 2020/1/19 1:42 下午
     */
    public static function bootOrderByIdDesc(): void
    {
        static::addGlobalScope(function (Builder $builder) {
            $builder->orderByDesc('id');
        });
    }

}
