feat: phase 2 — master data (products, customers, drivers) via InsForge-backed Filament pages
This commit is contained in:
@@ -40,17 +40,17 @@ class InsForgeClient
|
||||
return $this->request('GET', '/api/auth/profiles/current')->json();
|
||||
}
|
||||
|
||||
public function listRecords(string $table, array $params = []): array
|
||||
public function listRecords(string $table, array $params = [], bool $asUser = false): array
|
||||
{
|
||||
return $this->request('GET', "/api/database/records/{$table}", query: $params)->json() ?? [];
|
||||
return $this->request('GET', "/api/database/records/{$table}", query: $params, asUser: $asUser)->json() ?? [];
|
||||
}
|
||||
|
||||
public function getRecord(string $table, string $id, array $params = []): ?array
|
||||
public function getRecord(string $table, string $id, array $params = [], bool $asUser = false): ?array
|
||||
{
|
||||
$params['id'] = 'eq.'.$id;
|
||||
$params['limit'] = 1;
|
||||
|
||||
return $this->listRecords($table, $params)[0] ?? null;
|
||||
return $this->listRecords($table, $params, $asUser)[0] ?? null;
|
||||
}
|
||||
|
||||
public function insertRecord(string $table, array $data, bool $asUser = true): array
|
||||
@@ -118,9 +118,11 @@ class InsForgeClient
|
||||
|
||||
$verb = strtolower($method);
|
||||
|
||||
$uri = $query !== [] ? $path.'?'.http_build_query($query) : $path;
|
||||
|
||||
$response = in_array($verb, ['get', 'head'])
|
||||
? $http->{$verb}($path, $query)
|
||||
: $http->{$verb}($path, $body);
|
||||
? $http->{$verb}($uri)
|
||||
: $http->{$verb}($uri, $body);
|
||||
|
||||
throw_unless($response->successful(), fn () => InsForgeException::fromResponse(
|
||||
$response->status(),
|
||||
|
||||
Reference in New Issue
Block a user