add sorting for every getData and navigator, Favourites need to be fixed

This commit is contained in:
Milos Holba
2020-12-08 19:14:53 +01:00
parent 2ba92ed3b6
commit 7e325c5101
8 changed files with 93 additions and 36 deletions

View File

@@ -36,6 +36,7 @@ class BrowseController extends Controller
->with(['parent'])
->where('user_id', $user_id)
->whereIn('unique_id', filter_folders_ids($folders_trashed))
->sortable()
->get();
// Get files trashed
@@ -43,6 +44,7 @@ class BrowseController extends Controller
->with(['parent'])
->where('user_id', $user_id)
->whereNotIn('folder_id', array_values(array_unique(recursiveFind($folders_trashed->toArray(), 'unique_id'))))
->sortable()
->get();
// Collect folders and files to single array
@@ -72,11 +74,13 @@ class BrowseController extends Controller
$folders = FileManagerFolder::with(['parent', 'shared:token,id,item_id,permission,protected,expire_in'])
->where('user_id', $user_id)
->whereIn('unique_id', $folder_ids)
->sortable()
->get();
$files = FileManagerFile::with(['parent', 'shared:token,id,item_id,permission,protected,expire_in'])
->where('user_id', $user_id)
->whereIn('unique_id', $file_ids)
->sortable()
->get();
// Collect folders and files to single array
@@ -91,7 +95,8 @@ class BrowseController extends Controller
public function latest() {
// Get User
$user = User::with(['latest_uploads'])
$user = User::with(['latest_uploads' => function($query) {
$query->sortable(); }])
->where('id', Auth::id())
->first();
@@ -107,7 +112,7 @@ class BrowseController extends Controller
// Get User
$uploads = FileManagerFile::with(['parent'])->where('user_id', Auth::id())
->whereUserScope('editor')->orderBy('created_at', 'DESC')->get();
->whereUserScope('editor')->sortable()->get();
return $uploads;
}
@@ -148,14 +153,12 @@ class BrowseController extends Controller
$folders = FileManagerFolder::with(['parent', 'shared:token,id,item_id,permission,protected,expire_in'])
->where('user_id', $user_id)
->where('parent_id', $unique_id)
// ->orderBy('created_at', 'DESC')
->sortable(['name', 'DESC'])
->get();
$files = FileManagerFile::with(['parent', 'shared:token,id,item_id,permission,protected,expire_in'])
->where('user_id', $user_id)
->where('folder_id', $unique_id)
// ->orderBy('created_at', 'DESC')
->sortable(['name', 'DESC'])
->get();