Package Data | |
---|---|
Maintainer Username: | swilla |
Maintainer Contact: | steve@tappnetwork.com (Steve Williamson) |
Package Create Date: | 2019-02-22 |
Package Last Update: | 2024-05-04 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2025-01-23 15:11:19 |
Package Statistics | |
---|---|
Total Downloads: | 133,654 |
Monthly Downloads: | 4,185 |
Daily Downloads: | 208 |
Total Stars: | 101 |
Total Watchers: | 10 |
Total Forks: | 33 |
Total Open Issues: | 16 |
A simple approach to interacting with Airtables.
You can install the package via composer:
composer require tapp/laravel-airtable
Publish the config file:
php artisan vendor:publish --provider="Tapp\Airtable\AirtableServiceProvider"
Define airtables account information in .env:
AIRTABLE_KEY=
AIRTABLE_BASE=
AIRTABLE_TABLE=
AIRTABLE_TYPECAST=false
AIRTABLE_KEY
Airtable is requiring personal access tokens for Authorization starting in 2024. A token can be created here: https://airtable.com/create/tokens. If you are upgrading from an API key to access token, simply replace the value previously held in this environment variable with your new token.AIRTABLE_BASE
can be found here: https://airtable.com/api, select base then copy from URL: https://airtable.com/[Base Is Here]/api/docs#curl/introduction
AIRTABLE_TABLE
can be found in the docs for the appropriate base, this is not case senstive. IE: tasks
AIRTABLE_TYPECAST
set this to true to allow automatic casting.If you need to support multiple tables, add them to the tables config in the config/airtable.php If your table is on a different base than the one set in the env, add that as well.
...
'tables' => [
'default' => [
'name' => env('AIRTABLE_TABLE', 'Main'),
'base' => 'base_id',
],
'companies' => [
'name' => env('AIRTABLE_COMPANY_TABLE', 'Companies'),
'base' => 'base_id',
],
...
],
...
use Airtable;
Airtable::table('tasks')->get();
Airtable::table('tasks')->all();
Airtable::table('tasks')->all(500000); // 0.5 seconds
Airtable::find('id_string');
Airtable::where('id', '5')->get();
Airtable::where('id', '>', '5')->get();
where
is not enough you may need to pass in raw filter values.Airtable::table('tasks')->filterByFormula('OR({id} = "abc", {id} = "def", {id} = "ghi")')->get();
asc
(default) or desc
Airtable::orderBy('id')->get();
Airtable::orderBy('created_at', 'desc')->get();
You can sort by multiple fields by calling orderBy
more than once (a single call with array syntax is not supported):
Airtable::orderBy('id')->orderBy('created_at', 'desc')->get();
Airtable::create(['name' => 'myName']);
Airtable::firstOrCreate(['name' => 'myName'], ['field' => 'myField']);
Airtable::updateOrCreate(['name' => 'myName'], ['field' => 'myField']);
Airtable::table('companies')->firstOrCreate(['Company Name' => $team->name]);
Note: Update is destructive and clear all unspecified cell values if you did not provide a value for them. use PATCH up update specified fields
Airtable::table('companies')->update('rec5N7fr8GhDtdNxx', [ 'name' => 'Google', 'country' => 'US']);
Airtable::table('companies')->patch('rec5N7fr8GhDtdNxx', ['country' => 'US']);
Airtable::table('companies')->patch([
[
'id' => 'rec5N7fr8GhDtdNxx',
'fields' => ['country' => 'US']
],
[
'id' => 'rec8BhDt4fs2',
'fields' => ['country' => 'UK']
],
...
]);
Airtable::table('companies')->destroy('rec5N7fr8GhDtdNxx');
composer test
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email steve@tappnetwork.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.
This package was generated using the Laravel Package Boilerplate.