> For the complete documentation index, see [llms.txt](https://docs.minical.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.minical.io/coming-soon/access-minical-data-using-helpers/room-helper-functions.md).

# Room Helper Functions

### function add\_room($room) {.....}

#### **Supported hooks**

**Filter name:**  before\_add\_room\
**Description:** This filter would be executed before add room into the database in add\_room  helper.\
**Usage:**

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

add_filter( ‘before_add_room’, ‘before_room_tax_callback_fun’, 10, 1 );

function before_add_room_callback_fun($room) {
 // code
}
```

**Filter name:**  should\_add\_room\
**Description:** This filter would be executed before add room into database in add\_room helper.\
**Usage:**

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

add_filter( ‘should_add_room’, ‘should_add_room_callback_fun’, 10, 1 );

function should_add_room_callback_fun($room) {
    // code
}
```

**hook name:**  pre.add.room \
**Description:** This hook would be executed before add room into the database in add\_room  helper.\
**Usage:**

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

add_action('pre.add.room', 'pre_add_room_callback_fun', 10, 1);

function pre_add_room_callback_fun($room) {
    // code
}
```

**hook name:**  post.add.room\
**Description:** This hook would be executed after add room into the database in add\_room helper.\
**Usage:**

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

add_action('post.add.room', 'post_add_room_callback_fun', 10, 1);

function post_add_room_callback_fun($tax) {
    // code
}
```

**Usage**

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

// add a new room in room table. you can only add a new room if your number_of_rooms capacity not full in company.
$room_id = add_room($room);
```

**Request Parameters**

Parameters in array format includes following attributes:

<table><thead><tr><th>Param</th><th>Type</th><th width="200">Required</th><th>Default</th><th>Description</th></tr></thead><tbody><tr><td>room_name</td><td>Character</td><td>Yes</td><td>Null</td><td>The room_name  of a specific room.</td></tr><tr><td>room_type_id</td><td>Integer</td><td>Yes</td><td>0</td><td>The room_type_id  for a specific room.</td></tr><tr><td>sort_order</td><td>Integer</td><td>Yes</td><td>0</td><td>The sort_order  for a specific room.</td></tr><tr><td>status</td><td>Character</td><td>Yes</td><td>Clean</td><td>The room status for a specific room.</td></tr><tr><td>group_id</td><td>Integer</td><td></td><td>0</td><td>The group_id  for a specific room.</td></tr><tr><td>floor_id</td><td>Integer</td><td></td><td>0</td><td>The floor_id for a specific room.</td></tr><tr><td>location_id</td><td>Integer</td><td></td><td>0</td><td>The location_id for a specific room.</td></tr><tr><td>score</td><td>Integer</td><td></td><td>0</td><td>The score for a specific room.</td></tr><tr><td>instructions</td><td>Text</td><td></td><td>Null</td><td>The instructions for a specific room.</td></tr><tr><td>can_be_sold_online</td><td>Integer</td><td></td><td>1</td><td>The can_be_sold_online for a specific room.</td></tr><tr><td>notes</td><td>Text</td><td></td><td>Null</td><td>The notes for a specific room.</td></tr><tr><td>company_id</td><td>Integer</td><td>Yes</td><td>Null</td><td>The company_id for specific room.</td></tr></tbody></table>

**Response**

```
Response includes the following attributes:
if data have been added successfully it would return the key of specific room id.

```

```php
return $room_id;
```

```
if data does not add it will return null.
```

### function get\_room($room\_id) {....}

#### **Supported hooks**

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

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

add_filter( ‘before_get_room’, ‘before_get_room_callback_fun’, 10, 1 );

function before_get_room_callback_fun($room_id) {
 // code
}
```

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

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

add_filter( ‘should_get_room’, ‘should_get_room_callback_fun’, 10, 1 );

function should_get_room_callback_fun($room_id) {
    // code
}
```

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

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

add_action('pre.get.room', 'pre_get_room_callback_fun', 10, 1);

function pre_get_room_callback_fun($room_id) {
    // code
}
```

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

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

add_action('post.get.room', 'post_get_room_callback_fun', 10, 1);

function post_get_room_callback_fun($room_id) {
    // code
}
```

**Usage**

```php
// Retrieves room data based on a room_id.
$room_data = get_room($room_id);
```

**Request Parameters**

| Param     | Type    | Required | Default | Description                                              |
| --------- | ------- | -------- | ------- | -------------------------------------------------------- |
| $room\_id | Integer | Yes      | Null    | The primary id of the room corresponds to the room table |

**Response**

```php
// $response array includes following attributes:
// $response['room_name'] : the room_name of specific room.
// $response['room_type_id'] : the room_type_id for specific room.
// $response['sort_order'] : the sort_order for specific room.
// $response['status'] : the status for specific room.
// $response['company_id'] : the company_id for specific room.
// $response['room_type_name'] : the room_type_name for specific room.
// $response['can_be_sold_online'] : the can_be_sold_online for specific room.
// and many more attributes for table room and join with room type table.

// Successfully response giving you array of room data.
Array
(
    [room_name] => 101
    [room_type_id] => 2
    [status] => Clean
    [notes] => 
    [room_id] => 11
    [is_deleted] => 0
    [company_id] => 1
    [can_be_sold_online] => 1
    [group_id] => 0
    [floor_id] => 0
    [location_id] => 0
    [sort_order] => 0
    [is_hidden] => 0
    [score] => 0
    [instructions] => 
    [id] => 2
    [name] => Sample Room Type
    [acronym] => SRT
    [max_occupancy] => 6
    [min_occupancy] => 1
    [max_adults] => 2
    [max_children] => 1
    [image_group_id] => 5
    [description] => 
    [ota_close_out_threshold] => 1
    [sort] => 0
    [default_room_charge] => 1
    [prevent_inline_booking] => 0
    [room_type_name] => Sample Room Type
)

// if there is no room data for any room id provided in input or any error will return null. 
```

### function get\_rooms($filter) {.....}

**Supported hooks**

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

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

add_filter( ‘before_get_rooms’, ‘before_get_rooms_callback_fun’, 10, 1 );

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

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

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

add_filter( ‘should_get_rooms’, ‘should_get_rooms_callback_fun’, 10, 1 );

function should_get_rooms_callback_fun($filter) {
    // code
}

```

**hook name:**  pre.get.rooms\
**Description:** This hook would be executed before retrieving room details from database in get\_rooms helper.\
**Usage:**

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

add_action('pre.get.rooms', 'pre_get_rooms_callback_fun', 10, 1);

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

**hook name:**  post.get.rooms\
**Description:** This hook would be executed after retrieving room details from database in get\_rooms helper.\
**Usage:**

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

add_action('post.get.rooms', 'post_get_rooms_callback_fun', 10, 1);

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

**Usage**

```php
// Retrieves room data based on a filter array.
$room_data = get_rooms($filter);
```

**Request Parameters**

parameter array filter required for room details.

| Param          | Type      | Required | Default | Description                            |
| -------------- | --------- | -------- | ------- | -------------------------------------- |
| room\_name     | Character | Yes      | Null    | The room\_name for a specific room.    |
| company\_id    | Integer   | Yes      | Null    | The company\_id  for specific room.    |
| room\_type\_id | Integer   | yes      | Null    | The room\_type\_id  for specific room. |

**Response**

```php
// $response array includes following attributes:
// $response['room_name'] : the room_name of specific room.
// $response['room_type_id'] : the room_type_id for specific room.
// $response['sort_order'] : the sort_order for specific room.
// $response['status'] : the status for specific room.
// $response['company_id'] : the company_id for specific room.
// $response['room_type_name'] : the room_type_name for specific room.
// $response['can_be_sold_online'] : the can_be_sold_online for specific room.
// and many more attributes for table room and join with room type table.

// Successfully response giving you array of room data.

Array
(
    [0] => Array
        (
            [room_name] => 101
            [room_type_id] => 2
            [status] => Clean
            [notes] => 
            [room_id] => 11
            [is_deleted] => 0
            [company_id] => 1
            [can_be_sold_online] => 1
            [group_id] => 0
            [floor_id] => 0
            [location_id] => 0
            [sort_order] => 0
            [is_hidden] => 0
            [score] => 0
            [instructions] => 
            [id] => 2
            [name] => Sample Room Type
            [acronym] => SRT
            [max_occupancy] => 6
            [min_occupancy] => 1
            [max_adults] => 2
            [max_children] => 1
            [image_group_id] => 5
            [description] => 
            [ota_close_out_threshold] => 1
            [sort] => 0
            [default_room_charge] => 1
            [prevent_inline_booking] => 0
        )

)

// if there is no room data for filter provided in input or any error will return null.
```

### function update\_room($room, $room\_id) {....}

**Usage**

```php
// update room data based on a update data and room_id.
 update_room($room, $room_id);
```

**Supported hooks**

**Filter name:**  before\_update\_room\
**Description:** This filter would be executed before update room into the database in update\_room helper.\
**Usage:**

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

add_filter( ‘before_update_room’, ‘before_update_room_callback_fun’, 10, 1 );

function before_update_room_callback_fun($room, $room_id) {
 // code
}
```

**Filter name:**  should\_update\_room\
**Description:** This filter would be executed before update room into database in update\_room helper.\
**Usage:**

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

add_filter( ‘should_update_room’, ‘should_update_room_callback_fun’, 10, 1 );

function should_update_room_callback_fun($room, $room_id) {
    // code
}
```

**hook name:**  pre.update.room\
**Description:** This hook would be executed before update room into the database in update\_room helper.\
**Usage:**

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

add_action('pre.update.room', 'pre_update_room_callback_fun', 10, 1);

function pre_update_room_callback_fun($room, $room_id) {
    // code
}
```

**hook name:**  post.update.room\
**Description:** This hook would be executed after update room into the database in update\_room helper.\
**Usage:**

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

add_action('post.update.room', 'post_update_room_callback_fun', 10, 1);

function post_update_room_callback_fun($room, $room_id) {
    // code
}
```

**Request Parameters**

Request required room\_id and  array format data includes following attributes:

<table><thead><tr><th>Param</th><th>Type</th><th width="200">Required</th><th>Default</th><th>Description</th></tr></thead><tbody><tr><td>room_id</td><td>Integer</td><td>Yes</td><td>Null</td><td>The room_id primary key of a specific room.</td></tr><tr><td>room_name</td><td>Character</td><td>Yes</td><td>Null</td><td>The room_name  of a specific room.</td></tr><tr><td>room_type_id</td><td>Integer</td><td>Yes</td><td>0</td><td>The room_type_id  for a specific room.</td></tr><tr><td>sort_order</td><td>Integer</td><td>Yes</td><td>0</td><td>The sort_order  for a specific room.</td></tr><tr><td>status</td><td>Character</td><td>Yes</td><td>Clean</td><td>The room status for a specific room.</td></tr><tr><td>group_id</td><td>Integer</td><td></td><td>0</td><td>The group_id  for a specific room.</td></tr><tr><td>floor_id</td><td>Integer</td><td></td><td>0</td><td>The floor_id for a specific room.</td></tr><tr><td>location_id</td><td>Integer</td><td></td><td>0</td><td>The location_id for a specific room.</td></tr><tr><td>score</td><td>Integer</td><td></td><td>0</td><td>The score for a specific room.</td></tr><tr><td>instructions</td><td>Text</td><td></td><td>Null</td><td>The instructions for a specific room.</td></tr><tr><td>can_be_sold_online</td><td>Integer</td><td></td><td>1</td><td>The can_be_sold_online for a specific room.</td></tr><tr><td>notes</td><td>Text</td><td></td><td>Null</td><td>The notes for a specific room.</td></tr><tr><td>company_id</td><td>Integer</td><td>Yes</td><td>Null</td><td>The company_id for specific room.</td></tr></tbody></table>

**Response**

```
Response return mixed Either true or null if room data is updated then true else null.
```

### **function delete\_**&#x72;oo&#x6D;**(**$room\_i&#x64;**) {.....}**

**Usage**

```php
// delete a room data from the room table. it's a soft delete process only status will change data still existing in the backend database.

 delete_room($room_id);
```

**Request Parameters**

| Param     | Type    | Required | Default | Description                                      |
| --------- | ------- | -------- | ------- | ------------------------------------------------ |
| $room\_id | integer | yes      | null    | The id of the room corresponds to the room table |

**Response**

```
Response return mixed Either true or null if room data is deleted then true 
else null.
```
