# LayoutColumns

## Introduction

`LayoutColumns` represent a column in a user defined [Layout](/api-reference/layouts/layouts.md). `LayoutColumns` are always related to a [LayoutRow](/api-reference/layouts/layout-rows.md) and may contain many `LayoutableElements`.

`LayoutableElements` are different models that can be assigned to a `LayoutColumn` via the [LayoutColumnLayoutElements](/api-reference/layouts/layout-column-layout-elements.md) intermidiate relation. Currently these are mainly [FormFields](/api-reference/forms/form-fields.md).

## Model Definition

### Alias

`layoutColumn`

### Relations

| Key                  | Relation                                                                              | Type           | Relation Field(s)                            |
| -------------------- | ------------------------------------------------------------------------------------- | -------------- | -------------------------------------------- |
| `layoutRow`          | [LayoutRow](/api-reference/layouts/layout-rows.md)                                    | Belongs to     | `layout_row_id`                              |
| `layoutableElements` | [LayoutColumnLayoutElements](/api-reference/layouts/layout-column-layout-elements.md) | Has many       | `layoutColumnLayoutElement.layout_column_id` |
| `formFields`         | [FormFields](/api-reference/forms/form-fields.md)                                     | Morphy to many |                                              |

### Traits

* `Sortable`
* `SoftDeletes`

## List

Get a list of all `LayoutColumns` available in the system.

**Definition**

<mark style="color:green;">`GET`</mark> `/api/layouts/columns`

**Example Request**

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

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

{% endtab %}
{% endtabs %}

**Example Response**

```json
[
  {
    "id": 1,
    "title": null,
    "layout_row_id": 1,
    "width": 12,
    "sort_number": 1,
    "created_at": "2021-10-25 19:07:59",
    "updated_at": "2021-10-25 19:07:59",
    "deleted_at": null
  },
  {
    "id": 2,
    "title": null,
    "layout_row_id": 2,
    "width": null,
    "sort_number": 1,
    "created_at": "2021-10-25 19:08:00",
    "updated_at": "2021-10-25 19:08:00",
    "deleted_at": null
  },
  {
    "id": 3,
    "title": null,
    "layout_row_id": 2,
    "width": null,
    "sort_number": 2,
    "created_at": "2021-10-25 19:08:00",
    "updated_at": "2021-10-25 19:08:00",
    "deleted_at": null
  }
]
```

## Show

Show a single `LayoutColumn` by `id`.

**Definition**

<mark style="color:green;">`GET`</mark> `/api/layouts/columns/{id}`

**Example Request**

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

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

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "id": 1,
  "title": null,
  "layout_row_id": 1,
  "width": 12,
  "sort_number": 1,
  "created_at": "2021-10-25 19:07:59",
  "updated_at": "2021-10-25 19:07:59",
  "deleted_at": null
}
```

## Create

Creates a new `LayoutColumn`

**Definition**

<mark style="color:yellow;">`POST`</mark> `/api/layouts/columns`

**Request Keys**

| Key               | Type    | Default            | Description                                                                                        |
| ----------------- | ------- | ------------------ | -------------------------------------------------------------------------------------------------- |
| `title`           | string  | `null`             | The title for the `LayoutColumn`.                                                                  |
| `layout_row_id`\* | integer | -                  | The `LayoutRow` this `LayoutColumn` belongs to.                                                    |
| `width`           | integer | `null`             | The displayed column width.                                                                        |
| `sort_number`     | integer | Current highest +1 | The index of the `LayoutColumn` related to the [LayoutRow](/api-reference/layouts/layout-rows.md). |

Keys with `*` are required.

#### Advanced Key-Specifications

* `width` - The maximum usable width in a row is `12`. Thus given a column can have a maximum width of `12` if it's a single column. When passing a different value than `null` (= flexible) the maximum value is calculated by substracting the cumulated width values of already existing columns from `12`.

Example: There are two `LayoutColumns` existing with a `width` of `4` and `6`. The maximum width for a third column would be `2` then.

***

**Example Request**

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

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('POST', '/api/layouts/columns', [
    'headers' => ['Authorization' => "Bearer {accessToken}"],
    'json' => [
        'title' => null,
        'layout_row_id' => '1',
        'width' => 'null',
        'sort_number' => '1',
    ]
]);

```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "status": "success",
  "data": {
    "id": 1,
    "title": null,
    "layout_row_id": 1,
    "width": null,
    "sort_number": 1,
    "created_at": "2023-04-28 13:55:21",
    "updated_at": "2023-04-28 13:55:21",
    "deleted_at": null
  }
}
```

## Update

Update an existing `LayoutColumn` by `id`.

**Definition**

<mark style="color:blue;">`PUT`</mark> `/api/layouts/columns/{id}`

**Request Keys**

| Key             | Type    | Default | Description                                                                                        |
| --------------- | ------- | ------- | -------------------------------------------------------------------------------------------------- |
| `title`         | string  | -       | The title for the `LayoutColumn`.                                                                  |
| `layout_row_id` | integer | -       | The `LayoutRow` this `LayoutColumn` belongs to.                                                    |
| `width`         | integer | -       | The displayed column width.                                                                        |
| `sort_number`   | integer | -       | The index of the `LayoutColumn` related to the [LayoutRow](/api-reference/layouts/layout-rows.md). |

**Example Request**

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

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('PUT', '/api/layouts/columns/1', [
    'headers' => ['Authorization' => "Bearer {accessToken}"],
    'json' => [
        'width' => '6',
    ]
]);
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "status": "success",
  "data": {
    "id": 1,
    "title": null,
    "layout_row_id": 1,
    "width": 6,
    "sort_number": 1,
    "created_at": "2023-04-28 13:55:21",
    "updated_at": "2023-04-28 13:55:21",
    "deleted_at": null
  }
}
```

## Delete

Delete an existing `LayoutColumn` by `id`.

**Definition**

<mark style="color:red;">`DELETE`</mark> `/api/layouts/columns/{id}`

**Example Request**

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

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('DELETE', '/api/layouts/columns/1', [
    '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/layouts/layout-columns.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.
