Get All Groups
Fetch the list of groups from your Traccar server.
WARNING
Standard users can only view groups they have access to. Admins and managers can view all groups.
Usage
Basic Usage
Use the ThingsTelemetry\Traccar\Facades\Group::all() method to retrieve all accessible groups.
php
use ThingsTelemetry\Traccar\Facades\Group;
$groups = Group::all(); // Illuminate\Support\Collection of GroupDataWith Filters
php
use ThingsTelemetry\Traccar\Facades\Group;
// Get all groups (admin/manager only)
$groups = Group::all(all: true);
// Get groups for a specific user
$groups = Group::all(userId: 42);
// Get groups without attributes (lighter response)
$groups = Group::all(excludeAttributes: true);
// Combine filters
$groups = Group::all(all: true, userId: 42, excludeAttributes: true);Query Parameters
| Parameter | Type | Description |
|---|---|---|
all | ?bool | If true, returns all groups (admin/manager only) |
userId | ?int | Filter groups accessible by a specific user |
excludeAttributes | ?bool | If true, excludes attributes from response for better performance |
Results
The response is a Illuminate\Support\Collection<int, ThingsTelemetry\Traccar\Dto\GroupData>.
php
$first = $groups->first();
$id = $first->id; // 1
$name = $first->name; // "Vehicles"
$groupId = $first->groupId; // null (top-level group)
$attributes = $first->attributes; // ['color' => 'blue']Key Result Items
id→?intUnique identifier for the group.name→stringHuman-readable group name.groupId→?intParent group ID for hierarchical groups (null for top-level).attributes→array<string, mixed>Custom attributes associated with the group.
Hierarchical Groups
Groups can be nested. Check the groupId property to determine parent-child relationships:
php
$groups = Group::all();
$topLevel = $groups->filter(fn ($g) => $g->groupId === null);
$children = $groups->filter(fn ($g) => $g->groupId === 1);Related Operations
- Get Group - Fetch a single group by ID
- Create Group - Create a new group
- Update Group - Update an existing group
- Delete Group - Remove a group