Fix sorting textures in skin library

This commit is contained in:
Pig Fang 2019-05-04 16:02:46 +08:00
parent 2eab303457
commit 85eefad0b1
3 changed files with 5 additions and 12 deletions

View File

@ -96,21 +96,12 @@ class SkinlibController extends Controller
$totalPages = ceil($query->count() / $itemsPerPage);
// Available sorting methods: time
$sort = $request->input('sort', 'time');
$sortBy = ($sort == 'time') ? 'upload_at' : $sort;
// `likes` property is not actually existed in database.
if ($sortBy != 'likes') {
$query->withCount('likers as likes');
$query = $query->orderBy($sortBy, 'desc');
}
$textures = $query->skip(($currentPage - 1) * $itemsPerPage)
->take($itemsPerPage)
->get();
if ($sortBy == 'likes') {
$textures = $textures->sortByDesc('likes')->values();
}
$textures = $query->skip(($currentPage - 1) * $itemsPerPage)->take($itemsPerPage)->get();
if ($user) {
$closet = $user->closet()->get();

View File

@ -2,3 +2,4 @@
- Fixed dropdown menu of skin library for mobile users.
- Fixed previewing alex textures.
- Fixed sorting textures in skin library.

View File

@ -2,3 +2,4 @@
- 修复移动端下皮肤库下拉菜单失效的问题
- 修复 Alex 材质的预览
- 修复皮肤库中的排序问题