新增order
This commit is contained in:
parent
dd0ad744e6
commit
e1abef2319
@ -178,4 +178,38 @@ class CatchQuery extends Query
|
||||
|
||||
return parent::paginate($listRows, $simple); // TODO: Change the autogenerated stub
|
||||
}
|
||||
|
||||
/**
|
||||
* order 排序
|
||||
*
|
||||
* @time 2020年04月30日
|
||||
* @param string $field
|
||||
* @param string $order
|
||||
* @param string $position
|
||||
* @return $this|CatchQuery
|
||||
*/
|
||||
public function order($field = '', string $order = 'desc', $position = 'backend')
|
||||
{
|
||||
if ($position = 'front') {
|
||||
parent::order($field, $order);
|
||||
}
|
||||
|
||||
if (property_exists($this, 'field')) {
|
||||
if (in_array('sort', $this->field)) {
|
||||
parent::order('sort', 'desc');
|
||||
}
|
||||
}
|
||||
|
||||
if ($position == 'middle') {
|
||||
parent::order($field, $order);
|
||||
}
|
||||
|
||||
parent::order($this->getPk(), 'desc');
|
||||
|
||||
if ($position == 'backend') {
|
||||
parent::order($field, $order);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ trait BaseOptionsTrait
|
||||
public function getList()
|
||||
{
|
||||
return $this->catchSearch()
|
||||
->order($this->getPk(), 'desc')
|
||||
->order()
|
||||
->paginate();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user