zlt / airtable
Easy To Use PHP SDK for Airtable API
Fund package maintenance!
v0.2.1
2022-12-13 06:35 UTC
Requires
- php: ^8.0
- ext-curl: *
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
This package also supports easy to use Search feature which is implemented under the hood of
filterByFormulaparameter. Check here for more details.
Table Of Contents
Installation
$ composer require zlt/airtable
Usage
-
Initialize
$client = new Client('token');
The base api endpoint is
https://api.airtable.com/v0/. You can change it by specifying the second parameter of the constructor.$client = new Client('token','custom-endpoint');
-
How to get appId, tableId and viewId
The format of the url is
https://airtable.com/{appId}/{tableId}/{viewId}. -
Set appId
$client->setAppId('appId');
-
Set tableId
$client->setTable('tableId');
-
Create a record
$client->create([ 'field1' => 'value1', 'field2' => 'value2', ]);
-
Create multiple records
$client->createMany([[ 'field1' => 'value1', 'field2' => 'value2', ],[ 'field1' => 'value1', 'field2' => 'value2', ]]);
-
Get a record
$client->get('recordId');
-
Get multiple records
$client->get(['recordId1','recordId2']);
-
Get all records in table
$client->all();
-
Update a record
$client->update('recordId',[ 'field1' => 'value1', 'field2' => 'value2', ]);
-
Update multiple records
$client->updateMany([ 'recordId1' => [ 'field1' => 'value1', 'field2' => 'value2', ], 'recordId2' => [ 'field1' => 'value1', 'field2' => 'value2', ], ]);
-
Delete a record
$client->delete('recordId');
-
Delete multiple records
$client->deleteMany(['recordId1','recordId2']);
-
Search
You can perform operations such as
where,whereOr,whereNot, andand.$client->search() ->whereNot('Name', 'Doe') ->whereOr('Name', 'John') ->and(function ($search) { return $search->where('Status', 'Active'); }) ->get()
Support me
I would be really appreciated if you buy me a coffee via Binance. 😄😄