23 lines
448 B
PHP
23 lines
448 B
PHP
<?php
|
||
|
||
namespace App\Traits;
|
||
|
||
use Illuminate\Database\Eloquent\Builder;
|
||
|
||
trait OrderByOrderAsc
|
||
{
|
||
|
||
/**
|
||
* Notes: 初始化trait,自动在模型中,注入作用域
|
||
* @Author: <C.Jason>
|
||
* @Date : 2020/1/19 1:42 下午
|
||
*/
|
||
public static function bootOrderByOrderAsc(): void
|
||
{
|
||
static::addGlobalScope(function (Builder $builder) {
|
||
$builder->orderBy('order')->orderByDesc('id');
|
||
});
|
||
}
|
||
|
||
}
|