Skip to content

Roles Request

Ben Sherred edited this page Nov 5, 2021 · 5 revisions

Introduction

Companies can group their members together using roles. These roles can also be assigned permissions to extend a members abilities. To get a companies roles you can execute the following code.

Getting Roles

To get the roles for a company, you can call the roles() method on the CompanyRequest. This will return an instance of RoleCollection.

<?php

require_once('vendor/autoload.php');

$client = new TruckersMP\APIClient();
$roles = $client->company(1)->roles()->get(); // This is instance of `RoleCollection`

You can then loop through the roles to get information about a specific role. For more information, check out the available methods on the Role Request page.

$roles = $client->company(1)->roles()->get();

$count = 0;
foreach ($roles as $role) {
    $count++;
}

echo "This company has {$count} roles";