Fixed organisations causing errors with user sorting thanks to a distinct()
This commit is contained in:
@@ -32,6 +32,7 @@ class UserSprunje extends UFUserSprunje
|
|||||||
|
|
||||||
protected $sortable = [
|
protected $sortable = [
|
||||||
'name',
|
'name',
|
||||||
|
'organisations',
|
||||||
'last_activity',
|
'last_activity',
|
||||||
'status',
|
'status',
|
||||||
];
|
];
|
||||||
@@ -57,6 +58,7 @@ class UserSprunje extends UFUserSprunje
|
|||||||
*/
|
*/
|
||||||
protected function sortOrganisations($query, $direction)
|
protected function sortOrganisations($query, $direction)
|
||||||
{
|
{
|
||||||
|
$query = $query->addSelect('organisations.name');
|
||||||
$query->orderBy('organisations.name', $direction);
|
$query->orderBy('organisations.name', $direction);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@@ -84,6 +86,56 @@ class UserSprunje extends UFUserSprunje
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sort based on last activity time.
|
||||||
|
*
|
||||||
|
* @param Builder $query
|
||||||
|
* @param string $direction
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
protected function sortLastActivity($query, $direction)
|
||||||
|
{
|
||||||
|
$query = $query->addSelect('activities.occurred_at');
|
||||||
|
$query->orderBy('activities.occurred_at', $direction);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sort based on last name.
|
||||||
|
*
|
||||||
|
* @param Builder $query
|
||||||
|
* @param string $direction
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
protected function sortName($query, $direction)
|
||||||
|
{
|
||||||
|
$query = $query->addSelect('last_name');
|
||||||
|
$query = $query->addSelect('first_name');
|
||||||
|
$query->orderBy('last_name', $direction)->orderBy('first_name', $direction);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sort active, unactivated, disabled.
|
||||||
|
*
|
||||||
|
* @param Builder $query
|
||||||
|
* @param string $direction
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
protected function sortStatus($query, $direction)
|
||||||
|
{
|
||||||
|
$query = $query->addSelect('flag_enabled');
|
||||||
|
$query = $query->addSelect('flag_verified');
|
||||||
|
$query->orderBy('flag_enabled', $direction)->orderBy('flag_verified', $direction);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the unpaginated count of items (before filtering) in this query.
|
* Get the unpaginated count of items (before filtering) in this query.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user