final class DashboardService

Supports admin dashboard operations.

Constants

STATUS_OPTIONS

Status filter options: value as stored in users.inactive => label.

Same value => label shape as ACL::getOptionsForForm().

Methods

static void
checkIfCurrentUser(User $user, string $redirect = '')

Warns if admin user is attempting to view an area they should not be.

static SearchFilter
userFilter(object $request)

Builds the search/filter definition for the admin user list. Always excludes the current user.

static array
paginateUsers(Pagination $pagination, SearchFilter $filter)

Returns list of paginated users matching the filter.

static int
totalUsers(SearchFilter $filter)

Returns the number of users matching the filter.

static array
userList(object $request, int $perPage = 10)

Builds the paginated, filtered user list as plain arrays. Shared by the initial React render and the JSON responses for page/sort/filter changes.

static array
userToArray(User $user)

Serializes a user for the dashboard. Only the fields the table needs; never pass whole models to the client (password hashes, tokens, etc.).

static array
optionList(array $options)

Converts value => label options to a list for React. A list keeps order and avoids PHP turning '0'/'1' keys into a JSON array.

Details

at line 24
static void checkIfCurrentUser(User $user, string $redirect = '')

Warns if admin user is attempting to view an area they should not be.

Parameters

User $user

The current user.

string $redirect

The destination for redirect.

Return Value

void

at line 47
static SearchFilter userFilter(object $request)

Builds the search/filter definition for the admin user list. Always excludes the current user.

Parameters

object $request

The request object.

Return Value

SearchFilter

at line 65
static array paginateUsers(Pagination $pagination, SearchFilter $filter)

Returns list of paginated users matching the filter.

Parameters

Pagination $pagination

Instance of Pagination class.

SearchFilter $filter

The active search/filter.

Return Value

array

An array of paginated users.

at line 75
static int totalUsers(SearchFilter $filter)

Returns the number of users matching the filter.

Parameters

SearchFilter $filter

The active search/filter.

Return Value

int

The number of matching users.

at line 87
static array userList(object $request, int $perPage = 10)

Builds the paginated, filtered user list as plain arrays. Shared by the initial React render and the JSON responses for page/sort/filter changes.

Parameters

object $request

The request object.

int $perPage

Users per page.

Return Value

array

{Users: array, pagination: array, filter: array}

at line 106
static array userToArray(User $user)

Serializes a user for the dashboard. Only the fields the table needs; never pass whole models to the client (password hashes, tokens, etc.).

Parameters

User $user

The user.

Return Value

array

at line 126
static array optionList(array $options)

Converts value => label options to a list for React. A list keeps order and avoids PHP turning '0'/'1' keys into a JSON array.

Parameters

array $options

value => label.

Return Value

array