anthonypauwels / airtable
Airtable客户端
0.1.0
2022-08-30 06:10 UTC
Requires
- php: ^8.0
- ext-json: *
- guzzlehttp/guzzle: ^7.5
This package is auto-updated.
Last update: 2024-09-09 18:23:41 UTC
README
Airtable客户端。
安装
使用composer安装此包。
composer require anthonypauwels/airtable
Laravel不使用自动发现
如果您不使用自动发现,请将ServiceProvider添加到config/app.php
中的providers数组中
Anthonypauwels\AirTable\Laravel\ServiceProvider::class,
然后在config/app.php
中添加此行到您的门面
'AirTable' => Anthonypauwels\AirTable\Laravel\AirTable::class,
使用方法
use Anthonypauwels\AirTable\AirTable; $airTable = new AirTable( [ 'key' => 'key**************', 'base' => 'app**************', 'url' => AirTable::API_URL, ] ); $recordsA = $airTable->table('Your table')->view('View')->get(); $recordsB = $airTable->table('Another table')->where('key', '=', 'value' )->view('In view this view')->get();
使用Laravel
将环境变量定义到您的.env文件中
AIRTABLE_KEY="key**************" AIRTABLE_BASE="app**************"
该包为Laravel应用程序提供了默认的Facade。您可以直接使用Facade调用方法,或者使用别名。
use Anthonypauwels\AirTable\Laravel\AirTable; $recordsA = AirTable::table('Your table')->view('View')->get();
API文档
AirTable
/** * Get a builder for a table from the default base */ function table(string $table_name): Builder; /** * Get a base */ function on(string $base_id): Base;
基础
/** * Get a builder for a table */ function table(string $table_name): Builder;
客户端
/** * Count the number of elements inside the query */ function count(): int; /** * If AirTable must perform an automatic data conversion from string values */ function typecast(bool $value): Builder; /** * Delay between request */ function delay(int $value): Builder; /** * Search for specific fields from records */ function fields(array|string $fields): Builder; /** * Filter records using a logical where operation */ function where(string $field, mixed $operator, $value = null): Builder; /** * Filter records using a raw query */ function whereRaw(string $formula): Builder; /** * Get records from a specific view */ function view(string $view_name): Builder; /** * Order records by a field and direction */ function orderBy(string $field, string $direction = 'asc'): Builder; /** * Set the limit value to get a limited number of records */ function limit(int $value): Builder; /** * Alias to limit method */ function take(int $value): Builder; /** * Set the offset value to get records from a specific page */ function offset(int $value): Builder; /** * Alias to offset method */ function skip(int $value): Builder; /** * Get records with a limit of 100 by page */ function get(): array; /** * Method alias to get, return all records */ function all(): array; /** * Get the first record */ function first(): array; /** * Find a record using his ID */ function find(string $id): array; /** * Insert a record */ function insert(array $data): array; /** * Update a record or many records. Destructive way */ function update(array|string $id, array $data = null): array; /** * Patch a single record or many records */ function patch(array|string $id, array $data = null): array; /** * Delete a single record */ function delete(string $id): array;
要求
PHP 8.0或更高版本