Skip to content

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 GroupData

With 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

ParameterTypeDescription
all?boolIf true, returns all groups (admin/manager only)
userId?intFilter groups accessible by a specific user
excludeAttributes?boolIf 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?int Unique identifier for the group.
  • namestring Human-readable group name.
  • groupId?int Parent group ID for hierarchical groups (null for top-level).
  • attributesarray<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);

Released under the MIT License.