mirror of
https://github.com/BookStackApp/BookStack.git
synced 2026-01-03 23:42:28 +03:00
Added latest activity into users list view
This commit is contained in:
@@ -10,6 +10,7 @@ use BookStack\Exceptions\UserUpdateException;
|
||||
use BookStack\Uploads\Image;
|
||||
use Exception;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Images;
|
||||
use Log;
|
||||
|
||||
@@ -56,13 +57,19 @@ class UserRepo
|
||||
|
||||
/**
|
||||
* Get all the users with their permissions in a paginated format.
|
||||
* @param int $count
|
||||
* @param $sortData
|
||||
* @return Builder|static
|
||||
*/
|
||||
public function getAllUsersPaginatedAndSorted($count, $sortData)
|
||||
public function getAllUsersPaginatedAndSorted(int $count, array $sortData): LengthAwarePaginator
|
||||
{
|
||||
$query = $this->user->with('roles', 'avatar')->orderBy($sortData['sort'], $sortData['order']);
|
||||
$sort = $sortData['sort'];
|
||||
if ($sort === 'latest_activity') {
|
||||
$sort = \BookStack\Actions\Activity::query()->select('created_at')
|
||||
->whereColumn('activities.user_id', 'users.id')
|
||||
->latest()
|
||||
->take(1);
|
||||
}
|
||||
|
||||
$query = $this->user->with(['roles', 'avatar', 'latestActivity'])
|
||||
->orderBy($sort, $sortData['order']);
|
||||
|
||||
if ($sortData['search']) {
|
||||
$term = '%' . $sortData['search'] . '%';
|
||||
|
||||
Reference in New Issue
Block a user