|
@@ -28,7 +28,15 @@ class Category extends Model
|
|
'status' => config('status.mysql.table_normal')
|
|
'status' => config('status.mysql.table_normal')
|
|
];
|
|
];
|
|
|
|
|
|
- return $this->where($where)->field($field)->select();
|
|
|
|
|
|
+ $order = [
|
|
|
|
+ 'listorder' => 'desc',
|
|
|
|
+ 'id' => 'desc',
|
|
|
|
+ ];
|
|
|
|
+
|
|
|
|
+ return $this->where($where)
|
|
|
|
+ ->field($field)
|
|
|
|
+ ->order($order)
|
|
|
|
+ ->select();
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -61,19 +69,4 @@ class Category extends Model
|
|
$data['update_time'] = time();
|
|
$data['update_time'] = time();
|
|
return $this->where(['id' => $id])->save($data);
|
|
return $this->where(['id' => $id])->save($data);
|
|
}
|
|
}
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 根据pid获取子分类的个数
|
|
|
|
- * @param $condition
|
|
|
|
- * @return mixed
|
|
|
|
- */
|
|
|
|
- public function getChildCountInPids($condition)
|
|
|
|
- {
|
|
|
|
- $where[] = ['pid', 'in', $condition['pid']];
|
|
|
|
- $where[] = ['status', '<>', config('status.mysql.table_delete')];
|
|
|
|
- return $this->where($where)
|
|
|
|
- ->field(['pid', 'count(*) as count'])
|
|
|
|
- ->group('pid')
|
|
|
|
- ->select();
|
|
|
|
- }
|
|
|
|
}
|
|
}
|