Skip to content

Commit 186e237

Browse files
authored
added_operator_to_where_function (#17)
* added_operator_to_where_function * Enhancements to match laravel where * Updated readme
1 parent 36bf122 commit 186e237

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,12 @@ Airtable::find('id_string');
7171
```
7272

7373
#### Filter records
74+
- First argument is the column name
75+
- Second argument is the operator or the value if you want to use equal '=' as an operator.
76+
- Third argument is the value of the filter
7477
``` php
75-
Airtable::where('name', 'myName')->get();
78+
Airtable::where('id', '5')->get();
79+
Airtable::where('id', '>', '5')->get();
7680
```
7781

7882
#### First or Create

src/Airtable.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,13 @@ public function table($table)
4848
return $this;
4949
}
5050

51-
public function where($column, $value)
51+
public function where($column, $operator, $value = null)
5252
{
53-
return $this->api->addFilter($column, '=', $value);
53+
if (is_null($value)) {
54+
return $this->api->addFilter($column, '=', $operator);
55+
} else {
56+
return $this->api->addFilter($column, $operator, $value);
57+
}
5458
}
5559

5660
public function firstOrCreate(array $idData, array $createData = [])

0 commit comments

Comments
 (0)