Files
water_new/app/Traits/OrderByIdDesc.php
2023-03-08 09:16:04 +08:00

22 lines
494 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace App\Traits;
use App\Scopes\OrderByIdDescScope;
trait OrderByIdDesc
{
/**
* Notes: 初始化trait自动在模型中注入作用域
* 需要对拥有排序的模型,不需要使用排序的时候
* Model::withoutGlobalScope(new OrderByIdDescScope)
*
* @Author: <C.Jason>
* @Date : 2020/1/19 1:42 下午
*/
public static function bootOrderByIdDesc(): void
{
static::addGlobalScope(new OrderByIdDescScope);
}
}