Skip to content

Commit e7dbd56

Browse files
authored
adds support for multiple bases in config (#54)
* adds support for multiple bases in config * fixes style/ci issue
1 parent 9bde8f5 commit e7dbd56

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,20 @@ AIRTABLE_TYPECAST=false
3838
## Example Config
3939

4040
If you need to support multiple tables, add them to the tables config in the config/airtable.php
41+
If your table is on a different base than the one set in the env, add that as well.
4142

4243
```
4344
...
4445
'tables' => [
4546
4647
'default' => [
4748
'name' => env('AIRTABLE_TABLE', 'Main'),
49+
'base' => 'base_id',
4850
],
4951
5052
'companies' => [
5153
'name' => env('AIRTABLE_COMPANY_TABLE', 'Companies'),
54+
'base' => 'base_id',
5255
],
5356
...
5457
],

src/AirtableManager.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,16 @@ public function setDefaultTable($name)
100100
protected function resolve($name)
101101
{
102102
$config = $this->getConfig($name);
103-
104103
if ($config) {
105-
return $this->createAirtable($config['name']);
104+
return $this->createAirtable($config['name'], array_key_exists('base', $config) ? $config['base'] : false);
106105
} else {
107106
throw new InvalidArgumentException("Table [{$name}] is not configured.");
108107
}
109108
}
110109

111-
protected function createAirtable($table)
110+
protected function createAirtable($table, $table_base = false)
112111
{
113-
$base = $this->app['config']['airtable.base'];
112+
$base = $table_base ?: $this->app['config']['airtable.base'];
114113
$access_token = $this->app['config']['airtable.key'];
115114

116115
if ($this->app['config']['airtable.log_http']) {

0 commit comments

Comments
 (0)