-
Notifications
You must be signed in to change notification settings - Fork 15
Members Request
A company can have multiple members and you can these members by using the examples shown below. If you want to get a specific member, check out the Member Request page.
To get the members for a company, you can call the members()
method on the CompanyRequest
. This will return an instance of CompanyMemberIndex
.
<?php
require_once('vendor/autoload.php');
$client = new TruckersMP\APIClient();
$members = $client->company(1)->members()->get(); // This is instance of `CompanyMemberIndex`
The CompanyMemberIndex
class has a couple of methods to get additional information about the company members.
The getMembers
method returns an instance of MemberCollection
which is an array of CompanyMember
models. Below is an example of how you might get the names of all the members in the company.
$names = [];
$members = $client->company(1)->members()->get();
foreach ($members->getMembers() as $member) {
array_put($names, $member->getName());
}
echo implode(', ', $names);
The getCount
method returns the number members in the company.
$members = $client->company(1)->members()->get();
$count = $members->getCount();
echo "There are {$count} members in this company.";
If you have any questions about the library, you can create a topic on our forum.
This package is open-source and is licensed under the MIT license.