> For the complete documentation index, see [llms.txt](https://lakm.gitbook.io/helpdesk/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lakm.gitbook.io/helpdesk/sdk/queries/dashboard.md).

# Dashboard

Namespace: `LakM\HelpdeskBackend\Queries`. All methods are static counters or aggregations powering the dashboard endpoints.

## Counters

| Method                                 | Returns | Description                             |
| -------------------------------------- | ------- | --------------------------------------- |
| `agentsCount()`                        | `int`   | Total administrative users              |
| `ticketsCount()`                       | `int`   | Total tickets                           |
| `assignedTicketsCount()`               | `int`   | Tickets with at least one assignee      |
| `unassignedTicketsCount()`             | `int`   | Tickets without an assignee             |
| `myTicketsCount(User $user)`           | `int`   | Tickets assigned to the user            |
| `answeredTicketsCount()`               | `int`   | Answered tickets                        |
| `unansweredTicketsCount()`             | `int`   | Unanswered tickets                      |
| `myAnsweredTicketsCount(User $user)`   | `int`   | Answered tickets assigned to the user   |
| `myUnansweredTicketsCount(User $user)` | `int`   | Unanswered tickets assigned to the user |
| `customersCount()`                     | `int`   | Distinct ticket owners                  |
| `categoriesCount()`                    | `int`   | Total categories                        |

## Status and folder breakdowns

| Method                                       | Returns   | Description                                      |
| -------------------------------------------- | --------- | ------------------------------------------------ |
| `ticketsCountByStatusQuery()`                | `Builder` | Base builder for the status breakdown            |
| `ticketsCountByStatus()`                     | `?object` | Tickets grouped by status                        |
| `myTicketsCountByStatus(User $user)`         | `?object` | Status breakdown for the user's tickets          |
| `myAssignedTicketsCountByStatus(User $user)` | `?object` | Status breakdown for the user's assigned tickets |
| `foldersCountByType()`                       | `object`  | Tickets grouped by folder                        |

## Distribution over a period

| Method                                                            | Returns      | Description                                 |
| ----------------------------------------------------------------- | ------------ | ------------------------------------------- |
| `ticketsDistributionBaseQuery(DashboardFilters $filters)`         | `Builder`    | Base builder filtered by `DashboardFilters` |
| `allTimeTicketsDistribution(DashboardFilters $filters)`           | `array`      | Distribution across all time                |
| `ticketsDistributionByDuration(DashboardFilters $filters)`        | mixed        | Distribution for the given period           |
| `categoryNames()`                                                 | `Collection` | Names of all categories                     |
| `ticketCategoryDistributionByDuration(DashboardFilters $filters)` | mixed        | Tickets grouped by category                 |
| `ticketStatusDistributionByDuration(DashboardFilters $filters)`   | mixed        | Tickets grouped by status                   |
| `ticketPriorityDistributionByDuration(DashboardFilters $filters)` | mixed        | Tickets grouped by priority                 |

```php
use LakM\HelpdeskBackend\Data\DashboardFilters;
use LakM\HelpdeskBackend\Queries\DashboardQuery;

$total = DashboardQuery::ticketsCount();
$distribution = DashboardQuery::ticketStatusDistributionByDuration(DashboardFilters::fromRequest($request));
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://lakm.gitbook.io/helpdesk/sdk/queries/dashboard.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
