Skip to content

Commit 9257595

Browse files
authored
Add filter by formula functionality (#70)
* add filter by formula functionality * add linebreak * fix styleci error * add example to readme
1 parent 9ddef79 commit 9257595

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,13 @@ Airtable::where('id', '5')->get();
9494
Airtable::where('id', '>', '5')->get();
9595
```
9696

97+
### Filter records by formula
98+
- When using `where` is not enough you may need to pass in raw filter values.
99+
- [Airtable reference](https://support.airtable.com/docs/formula-field-reference)
100+
``` php
101+
Airtable::table('tasks')->filterByFormula('OR({id} = "abc", {id} = "def", {id} = "ghi")')->get();
102+
```
103+
97104
#### Sorting records
98105

99106
- First argument is the column name

src/Airtable.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,13 @@ public function where($column, $operator, $value = null)
106106
return $this;
107107
}
108108

109+
public function filterByFormula($formula)
110+
{
111+
$this->api->addFilterByFormula($formula);
112+
113+
return $this;
114+
}
115+
109116
public function orderBy(string $column, string $direction = 'asc')
110117
{
111118
$this->api->addSort($column, $direction);

src/Api/AirtableApiClient.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ public function addFilter($column, $operation, $value): AirtableApiClient
4848
return $this;
4949
}
5050

51+
public function addFilterByFormula(string $formula): AirtableApiClient
52+
{
53+
$this->filters[] = $formula;
54+
55+
return $this;
56+
}
57+
5158
public function addSort(string $column, string $direction = 'asc'): AirtableApiClient
5259
{
5360
if ($direction === 'desc') {

0 commit comments

Comments
 (0)