TappNetwork / laravel-airtable

Airtables Client for Laravel
MIT License
98 stars 35 forks source link

Multiple base connection #64

Open ghost opened 1 year ago

ghost commented 1 year ago

Is there a way of having multiple base connection like : 'base' => [ 'base1' => env('AIRTABLE_BASEID1'), 'base2' => env('AIRTABLE_BASEID2'), ... ],

And so, directly from this previous connection, picking table name like this : Airtable::table('TableName')->get();

Bc if i have like 5 base with 20 tables in each i would have to hard write 100 table connection in airtable.php like this : 'tables' => [ 'Table1FromBase1' => [ 'name' => 'Table1_name', 'base' => 'baseid1' ], ... (x100) ],

Or am i missing something ?

ghost commented 1 year ago

I have found an alternative solution tho, You can put something like this in the top of airtable.php before the return : $tables = [ 'TableName1', 'TableName2' ... ]; $basekey = [ "BaseNamePrefix1" => "basekey1", "BaseNamePrefix2" => "basekey2" ];

$airtableTables = [];

foreach ($basekey as $key => $value) { foreach ($tables as $k => $v) { $airtableTables[$key . '_' . $v] = [ 'name' => $v, 'base' => $value ]; } }

And in the return "Default Airtable Table" section : 'tables' => $airtableTables,