# Availability Helper Functions

### **function get\_**&#x61;vailability($filter) {....}

#### **Supported hooks**

**Filter name:**  before\_get\_availability\
Description: This filter would be executed before retrieving availability details from database in get\_availability helper.\
**Usage:**

```php
// The filter callback function is based on the filter.

add_filter( ‘before_get_availability’, ‘before_get_availability_callback_fun’, 10, 1 );

function before_get_availability_callback_fun($filter) {
// code
}
```

**Filter name:**  should\_get\_availability\
Description: This filter would be executed before retrieving availability details from the database in the get\_availability helper.\
Usage:

```php
// The filter callback function is based on the filter.

add_filter( ‘should_get_availability’, ‘should_get_availability_callback_fun’, 10, 1 );

function should_get_availability_callback_fun($filter) {
// code
}

```

**hook name:**  pre.get.availability\
**Description:** This hook would be executed before retrieving availability details from the database in the get\_availability helper.\
**Usage:**

```php
// The filter callback function is based on the filter.

add_action('pre.get.availability', 'pre_get_availability_callback_fun', 10, 1);

function pre_get_availability_callback_fun($filter) {
// code
}
```

**hook name:**  post.get.availability\
**Description:** This hook would be executed after retrieving availability details from the database in the get\_availability helper.\
**Usage:**

```php
// The filter callback function is based on the filter.

add_action('post.get.availability', 'post_get_availability_callback_fun', 10, 1);

function post_get_availability_callback_fun($filter) {
// code
}
```

**Usage**

```php
// for use company helper you need to add this helper on controller or
// you can autoload this helper.
$this->load->helper('includes/availability');

// Retrieves room availability data based on the filter.
$availability_data = get_availability($filter);
```

**Request Parameters**

```
Param array $filter (Required)  for availability details.
```

<table><thead><tr><th>Param</th><th>Type</th><th width="150">Required</th><th>Default</th><th>Description</th></tr></thead><tbody><tr><td>company_id</td><td>Integer</td><td>Yes</td><td>Null</td><td>The company_id of specific company(must require).</td></tr><tr><td>ota_id</td><td>Integer</td><td>Yes</td><td>Null</td><td>The ota_id of any specific OTA type (must require)</td></tr><tr><td>start_date</td><td>Date_time</td><td>Yes</td><td>Null</td><td>The start_date of any specific availability data (must required)</td></tr><tr><td>end_date</td><td>Date_time</td><td>Yes</td><td>Null</td><td>The end_date of any specific availability data(must require)</td></tr><tr><td>adult_count</td><td>Integer</td><td></td><td>Null</td><td>The adult_count of any specific availability</td></tr><tr><td>children_count</td><td>Integer</td><td></td><td>Null</td><td>The children_count of any specific availability</td></tr><tr><td>filter_can_be_sold_online</td><td>Boolean</td><td></td><td>True</td><td>The filter_can_be_sold_online of any specific availability.</td></tr><tr><td>company_group_id</td><td>Integer</td><td></td><td>Null</td><td>The company_group_id of any specific availability.</td></tr><tr><td>get_max_availability</td><td>Boolean</td><td></td><td>True</td><td>The get_max_availability of any specific availability.</td></tr><tr><td>get_inventorysold</td><td>Boolean</td><td></td><td>True</td><td>The get_inventorysold of any specific availability.</td></tr><tr><td>get_closeout_status</td><td>Boolean</td><td></td><td>True</td><td>The get_closeout_status of any specific availability.</td></tr><tr><td>get_inventory</td><td>Boolean</td><td></td><td>True</td><td>The get_inventory of any specific availability.</td></tr><tr><td>ota_key</td><td>Character</td><td></td><td>Null</td><td>The ota_key of any specific availability.</td></tr></tbody></table>

**Response**

```php
// Response array includes multiple array of availability for room type have following attributes:
// $response['id'] : the id of specific room types.
// $response['company_id'] : the company_id for specific room types.
// $response['rate_plan_count'] : the rate_plan_count for specific room types.
// $response['max_occupancy'] : the max_occupancy for specific room types.
// $response['max_adult'] : the max_adult for specific room types.
// $response['max_children'] : the max_children for specific room types.
// $response['default_room_charge'] : the default_room_charge for specific room types.
// $response['date_start'] : the date_start for specific room availability.
// $response['date_end'] : the date_end for specific room availability.
// $response['availability'] : the availability for specific room availability.
// $response['max_availability'] : the max_availability for specific room availability.
// $response['max_availability'] : the name for specific room availability.
// $response['inventory_sold'] : the inventory_sold for specific room availability.
// and many more attributes from availability and join with room , room type table.

// Successfully response giving you array of availability data.

Array
(
    [2] => Array
        (
            [id] => 2
            [name] => Sample Room Type
            [company_id] => 1
            [acronym] => SRT
            [is_deleted] => 0
            [max_occupancy] => 6
            [min_occupancy] => 1
            [max_adults] => 2
            [max_children] => 1
            [image_group_id] => 5
            [description] => 
            [can_be_sold_online] => 1
            [ota_close_out_threshold] => 1
            [sort] => 0
            [default_room_charge] => 1
            [prevent_inline_booking] => 0
            [rate_plan_count] => 2
            [availability] => Array
                (
                    [0] => Array
                        (
                            [date_start] => 2022-02-02
                            [date_end] => 2022-02-03
                            [date] => 2022-02-03
                            [availability] => 3
                            [max_availability] => 4
                            [inventory_sold] => 0
                            [closeout_status] => 1
                        )

                )

        )

    [3] => Array
        (
            [id] => 3
            [name] => Super Room Type
            [company_id] => 1
            [acronym] => NRT
            [is_deleted] => 0
            [max_occupancy] => 11
            [min_occupancy] => 1
            [max_adults] => 4
            [max_children] => 4
            [image_group_id] => 6
            [description] => 
            [can_be_sold_online] => 1
            [ota_close_out_threshold] => 1
            [sort] => 0
            [default_room_charge] => 1
            [prevent_inline_booking] => 0
            [rate_plan_count] => 2
            [availability] => Array
                (
                    [0] => Array
                        (
                            [date_start] => 2022-02-02
                            [date_end] => 2022-02-03
                            [date] => 2022-02-03
                            [availability] => 2
                            [max_availability] => 3
                            [inventory_sold] => 0
                            [closeout_status] => 1
                        )

                )

        )

// if there is no availability data for filter provided in input or any error will return 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.minical.io/coming-soon/access-minical-data-using-helpers/availability-helper-functions.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.
