enforceOrderBy
This commit is contained in:
parent
1fe0249fac
commit
7f47508627
@ -619,6 +619,20 @@ abstract class Repository implements RepositoryInterface, CacheableInterface, Cr
|
||||
return $this->sync($id, $relation, $attributes, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a generic "order by" clause if the query doesn't already have one.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function enforceOrderBy()
|
||||
{
|
||||
if ($this->model instanceof EloquentBuilder) {
|
||||
if (empty($this->model->getQuery()->orders) && empty($this->model->getQuery()->unionOrders)) {
|
||||
$this->orderBy($this->getModel()->getQualifiedKeyName(), 'asc');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回空值
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user