first
This commit is contained in:
23
app/Scopes/OrderByOrderAscScope.php
Normal file
23
app/Scopes/OrderByOrderAscScope.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Scopes;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Scope;
|
||||
|
||||
class OrderByOrderAscScope implements Scope
|
||||
{
|
||||
/**
|
||||
* Notes : 按照 order 字段 正序排序的作用域
|
||||
*
|
||||
* @Date : 2021/11/10 10:16 上午
|
||||
* @Author : <Jason.C>
|
||||
* @param Builder $builder
|
||||
* @param Model $model
|
||||
*/
|
||||
public function apply(Builder $builder, Model $model): void
|
||||
{
|
||||
$builder->orderBy('order')->orderByDesc('id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user