-
Notifications
You must be signed in to change notification settings - Fork 15
Post Request
Companies have a news feature which is made up of posts. To get the information about a post, you can execute the following code.
To get the information about a post, you can call the post(int $id) method on an instance of CompanyRequest. This will return an instance of CompanyPost.
<?php
require_once('vendor/autoload.php');
$client = new TruckersMP\APIClient();
$pst = $client->company(17)->role(121)->get(); // This is an instance of `CompanyPost`The CompanyPost model has a couple of methods to get additional information about the company role.
The getId method returns the ID of the post.
$post = $client->company(17)->role(121)->get();
echo 'The ID of this post is ' . $post->getId();The getTitle method returns the title of the post.
$post = $client->company(17)->post(121)->get();
echo $post->getTitle();The getSummary method returns a summary of the post.
$post = $client->company(17)->post(121)->get();
echo 'Post summary: ' . $member->getSummary();The getContent method returns the content of the post.
$post = $client->company(17)->post(121)->get();
echo $post->getContent();The getAuthor method returns the name of the author who made the post.
$post = $client->company(17)->post(121)->get();
echo 'Author: ' . $post->getAuthor();The getAuthorId method returns the ID of the author who wrote the post.
$post = $client->company(17)->post(121)->get();
echo 'The ID of the author is ' . $post->getAuthorId();The isPinned method returns whether or not the post is pinned to the companies page.
$post = $client->company(17)->post(121)->get();
if ($post->isPinned()) {
echo 'This post is pinned';
} else {
echo 'This post is not pinned';
}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.