-
Notifications
You must be signed in to change notification settings - Fork 15
Companies Request
Ben Sherred edited this page Dec 7, 2019
·
2 revisions
To get the most recent and featured companies, you can call the companies()
method on the Client
instance like so:
<?php
require_once('vendor/autoload.php');
$client = new TruckersMP\APIClient\Client();
$companies = $client->companies()->get();
This will return an instance of the CompanyIndex
model.
The model has a few helpful getters to get the recent and featured companies.
Method | Type | Description |
---|---|---|
getRecent() |
CompanyCollection | The recent companies that have been created |
getFeatured() |
CompanyCollection | The featured companies |
getFeaturedCovered() |
CompanyCollection | The companies featured on the VTC cover page |
Each getter returns an instance of CompanyCollection
. You can loop through the collection, as shown below, which will return an instance of the Company
model. For more information on this model, please refer to the Company Request page.
Below is an example of how you would loop through the collection.
<?php
require_once('vendor/autoload.php');
$client = new TruckersMP\APIClient\Client();
$companies= $client->companies()->get();
foreach ($companies->getRecent() as $company) {
// $company is an instance of the `Company` model
}
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.