Skip to content

Role Request

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

Introduction

Each company member is assigned a role when they join a company. This role is then assigned permissions to give the player access to additional features within the company. To get the information about a role, you can execute the following commands.

Getting a Role

To get the information about a role, you can call the role(int $id) method on an instance of CompanyRequest. This will return an instance of CompanyRole.

<?php

require_once('vendor/autoload.php');

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

Available Methods

The CompanyRole model has a couple of methods to get additional information about the company role.

Method Listing

getId()

The getId method returns the ID of the role.

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

echo 'The ID of the requested role is ' . $role->getId();

getName()

The getName method returns the name of the role.

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

echo 'The name of the role is ' . $role->getName();

getOrder()

The getOrder method returns the the order in which the role is displayed (0 being the highest).

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

echo 'This roles order ID is ' . $member->getOrder();

isOwner()

The isOwner method returns if the role is the owner of the company.

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

if ($role->isOwner()) {
    echo 'This role is the owner role';
} else {
    echo 'This role is not the owner role';
}

getCreatedAt()

The getCreatedAt method returns the date the role was created as an instance of Carbon. For more information on dates, please refer to the timestamps page.

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

echo 'This role was created ' . $role->diffForHumans();

getUpdatedAt()

The getUpdatedAt method returns the date the role was last updated as an instance of Carbon. For more information on dates, please refer to the timestamps page.

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

echo 'This role was updated ' . $role->diffForHumans();