123456789101112131415161718192021222324252627282930313233 |
- <?php
- namespace app\utils\VueAdmin;
- use think\Request;
- class AdminData {
- public static function orderBy($default = '')
- {
- $sorts = Request::instance()->param('prop');
- $orders = Request::instance()->param('orderBy', 'desc');
- $orders = $orders == 'asc' ? 'asc' :'desc';
- $order = [];
- if(!($sorts) || $sorts == 'null' || $sorts == 'undefined')
- {
- if($default = explode(',', $default))
- {
- if(isset($default[1]) && $default[0] && $default[1]) {
- $order[] = ['sort'=>$default[0], 'orderBy'=>$default[1]];
- }
- }
- }else{
- $sorts = explode(',',$sorts);
- foreach ($sorts as $sort){
- $order[] = [
- 'sort' => $sort,
- 'orderBy' => $orders
- ];
- }
- }
- return $order;
- }
- }
|