# InfoboardComments

`InfoboardComments` are used to enable a direct exchange on the content of an [InfoboardPost](/api-reference/infoboard/infoboard-posts.md).

## Model Definition

**Alias**

`infoboardComment`

### Relations

| Key               | Relation                                                     | Type       | Relation Field(s)                                                         |
| ----------------- | ------------------------------------------------------------ | ---------- | ------------------------------------------------------------------------- |
| `user`            | [User](/api-reference/users.md)                              | Belongs to | `user_id`                                                                 |
| `post`            | [InfoboardPost](/api-reference/infoboard/infoboard-posts.md) | Belongs to | `post_id`                                                                 |
| `notifications`   | [Notifications](/api-reference/notifications.md)             | Has many   | `notifications.event_id`, `notifications.event_source`                    |
| `reactions`       | [Reactions](/api-reference/reactions.md)                     | Morph many | `reactions.reactable_type`, `reactions.reactable_id`                      |
| `currentReaction` | [CurrentReaction](/api-reference/reactions.md)               | Morph one  | `reactions.reactable_type`, `reactions.reactable_id`, `reactions.user_id` |

### Computed properties

* `hash` - The hashed `id` of the `InfoboardComment`.

### Traits

* `TriggersNotifications`

## List

Get a list of all `InfoboardComments` the current authenticated [User](/api-reference/users.md) is allowed to view.

**Definition**

<mark style="color:green;">`GET`</mark> `/api/infoboard/posts/comments`

**Example Request**

{% tabs %}
{% tab title="PHP" %}

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('GET', '/api/infoboard/posts/comments', [
    'headers' => ['Authorization' => "Bearer {accessToken}"]
]);
```

{% endtab %}
{% endtabs %}

**Example Response Body**

```json
[
  {
    "id": 1,
    "user_id": 3,
    "post_id": 1,
    "text": "<p>At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p>",
    "created_at": "2018-12-21 11:44:50",
    "updated_at": "2018-12-21 11:54:40",
    "hash": "zn7m24owk63qolxryge8pj05"
  },
  {
    "id": 2,
    "user_id": 3,
    "post_id": 1,
    "text": "<p>Sollicitudin nibh sit amet commodo nulla facilisi nullam vehicula. Libero enim sed faucibus turpis in eu.</p>",
    "created_at": "2018-12-21 12:09:08",
    "updated_at": "2018-12-21 12:09:08",
    "hash": "6o8m0kz5yw10x1pr9e4vxj27"
  }
]
```

## List by Post

Get a list of all `InfoboardComments` the current authenticated [User](/api-reference/users.md) is allowed to view by [InfoboardPost](/api-reference/infoboard/infoboard-posts.md).

**Definition**

<mark style="color:green;">`GET`</mark> `/api/infoboard/posts/{postId}/comments`

**Example Request**

{% tabs %}
{% tab title="PHP" %}

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('GET', '/api/infoboard/posts/1/comments', [
    'headers' => ['Authorization' => "Bearer {accessToken}"]
]);
```

{% endtab %}
{% endtabs %}

**Example Response Body**

```json
[
  {
    "id": 1,
    "user_id": 3,
    "post_id": 1,
    "text": "<p>At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p>",
    "created_at": "2018-12-21 11:44:50",
    "updated_at": "2018-12-21 11:54:40",
    "hash": "zn7m24owk63qolxryge8pj05"
  },
  {
    "id": 2,
    "user_id": 3,
    "post_id": 1,
    "text": "<p>Sollicitudin nibh sit amet commodo nulla facilisi nullam vehicula. Libero enim sed faucibus turpis in eu.</p>",
    "created_at": "2018-12-21 12:09:08",
    "updated_at": "2018-12-21 12:09:08",
    "hash": "6o8m0kz5yw10x1pr9e4vxj27"
  }
]
```

## Show

Show a single `InfoboardComment` by `id` or `hash`.

**Definition**

<mark style="color:green;">`GET`</mark> `/api/infoboard/comments/{idOrHash}`

**Example Request**

{% tabs %}
{% tab title="PHP" %}

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('GET', '/api/infoboard/posts/comments/1', [
    'headers' => ['Authorization' => "Bearer {accessToken}"]
]);
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "id": 1,
  "user_id": 3,
  "post_id": 1,
  "text": "<p>At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p>",
  "created_at": "2018-12-21 11:44:50",
  "updated_at": "2018-12-21 11:54:40",
  "hash": "zn7m24owk63qolxryge8pj05"
}
```

## Create

Create a new `InfoboardComment` by [InfoboardPost](/api-reference/infoboard/infoboard-posts.md).

**Definition**

<mark style="color:yellow;">`POST`</mark> `/api/infoboard/posts/{postId}/comments`

**Request Keys**

| Key           | Type    | Default | Description                                                               |
| ------------- | ------- | ------- | ------------------------------------------------------------------------- |
| `post_id`\*\* | integer | -       | The related [InfoboardPost](/api-reference/infoboard/infoboard-posts.md). |
| `text`\*      | string  | -       | The content of the `InfoboardComment`.                                    |

Keys with `*` are required.\
Keys with `**` are normalized to the information given by the route.

**Example Request**

{% tabs %}
{% tab title="PHP" %}

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('POST', '/api/infoboard/posts/1/comments', [
    'headers' => ['Authorization' => "Bearer {accessToken}"],
    'json' => [
        'user_id' => 3,
        'text' => '<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>'
    ]
]);
```

{% endtab %}
{% endtabs %}

**Example Response Body**

```json
{
  "status": "success",
  "data": {
    "id": 3,
    "user_id": 3,
    "post_id": 1,
    "text": "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>",
    "updated_at": "2018-12-21 11:44:50",
    "created_at": "2018-12-21 11:44:50",
    "hash": "d54q7g6wnj1eylm8k9e0xpz2"
  }
}
```

## Update

Update an existing `InfoboardComment` by `id`.

**Definition**

<mark style="color:blue;">`PUT`</mark> `/api/infoboard/posts/comments/{id}`

**Request Keys**

| Key      | Type   | Default | Description                            |
| -------- | ------ | ------- | -------------------------------------- |
| `text`\* | string | -       | The content of the `InfoboardComment`. |

Keys with `*` are required.

**Example Request**

{% tabs %}
{% tab title="PHP" %}

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('PUT', '/api/infoboard/posts/comments/3', [
    'headers' => ['Authorization' => "Bearer {accessToken}"],
    'json' => [
        'user_id' => 3,
        'text' => '<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Morbi blandit cursus risus at ultrices mi tempus imperdiet nulla.</p>'
    ]
]);
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "status": "success",
  "data": {
    "id": 3,
    "user_id": 3,
    "post_id": 1,
    "text": "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Morbi blandit cursus risus at ultrices mi tempus imperdiet nulla.</p>",
    "created_at": "2018-12-21 11:44:50",
    "updated_at": "2018-12-21 12:04:10",
    "hash": "d54q7g6wnj1eylm8k9e0xpz2"
  }
}
```

## Delete

Delete an existing `InfoboardComment` by `id`.

**Definition**

<mark style="color:red;">`DELETE`</mark> `/api/infoboard/posts/comments/{id}`

**Example Request**

{% tabs %}
{% tab title="PHP" %}

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('DELETE', '/api/infoboard/posts/comments/3', [
    'headers' => ['Authorization' => "Bearer {accessToken}"]
]);
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "status": "success",
  "data": null
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.api.intratool.de/api-reference/infoboard/infoboard-comments.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
