Skip to content

Commit

Permalink
fix: admin users page 500 error
Browse files Browse the repository at this point in the history
  • Loading branch information
olwalkey committed Jan 3, 2025
1 parent 2e18753 commit af45f83
Showing 1 changed file with 28 additions and 16 deletions.
44 changes: 28 additions & 16 deletions app/Http/Controllers/Admin/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,34 @@ public function __construct(
/**
* Display user index page.
*/
public function index(Request $request): View
{
$users = QueryBuilder::for(
User::query()->select('users.*')
->selectRaw('COUNT(DISTINCT(subusers.id)) as subuser_of_count')
->selectRaw('COUNT(DISTINCT(servers.id)) as servers_count')
->leftJoin('subusers', 'subusers.user_id', '=', 'users.id')
->leftJoin('servers', 'servers.owner_id', '=', 'users.id')
->groupBy('users.id')
)
->allowedFilters(['username', 'email', 'uuid'])
->allowedSorts(['id', 'uuid'])
->paginate(50);

return $this->view->make('admin.users.index', ['users' => $users]);
}
public function index(Request $request): View
{
$users = QueryBuilder::for(
User::query()->select([
'users.id',
'users.username',
'users.email',
'users.created_at',
'users.updated_at',
])
->selectRaw('COUNT(DISTINCT(subusers.id)) as subuser_of_count')
->selectRaw('COUNT(DISTINCT(servers.id)) as servers_count')
->leftJoin('subusers', 'subusers.user_id', '=', 'users.id')
->leftJoin('servers', 'servers.owner_id', '=', 'users.id')
->groupBy([
'users.id',
'users.username',
'users.email',
'users.created_at',
'users.updated_at',
])
)
->allowedFilters(['username', 'email', 'uuid'])
->allowedSorts(['id', 'uuid'])
->paginate(50);

return $this->view->make('admin.users.index', ['users' => $users]);
}

/**
* Display new user page.
Expand Down

0 comments on commit af45f83

Please sign in to comment.