Skip to content

Commit 59f82d8

Browse files
author
David Nahodyl
committed
removed unnecessary properties, changed sorts to orders to use existing features better
1 parent 6a312e7 commit 59f82d8

File tree

2 files changed

+4
-59
lines changed

2 files changed

+4
-59
lines changed

src/Database/Query/FMBaseBuilder.php

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66

77
use BlueFeather\EloquentFileMaker\Exceptions\FileMakerDataApiException;
8-
use BlueFeather\EloquentFileMaker\Services\FileMakerConnection;
98
use Illuminate\Database\Query\Builder;
109
use Illuminate\Http\File;
1110
use Illuminate\Http\UploadedFile;
@@ -15,13 +14,6 @@
1514
class FMBaseBuilder extends Builder
1615
{
1716

18-
/**
19-
* The database connection instance.
20-
*
21-
* @var FileMakerConnection
22-
*/
23-
public $connection;
24-
2517
/**
2618
* The internal FileMaker Record ID to act on
2719
* @var
@@ -34,29 +26,6 @@ class FMBaseBuilder extends Builder
3426
*/
3527
protected $fieldMapping = [];
3628

37-
/**
38-
* The collection of sort orders for the query
39-
*
40-
* @var array
41-
*/
42-
public $sorts = [];
43-
44-
45-
/**
46-
* The maximum number of records to return.
47-
* Default is 100 for the FileMaker data API
48-
*
49-
* @var int
50-
*/
51-
public $limit;
52-
53-
/**
54-
* The number of records to skip.
55-
*
56-
* @var int
57-
*/
58-
public $offset;
59-
6029
/**
6130
* The name of the FileMaker script to be run after the action specified by the API call and after the subsequent sort.
6231
*
@@ -280,7 +249,7 @@ public function orderByDesc($column): FMBaseBuilder
280249

281250
protected function appendSortOrder($column, $direction)
282251
{
283-
$this->sorts[] = ['fieldName' => $this->getMappedFieldName($column), 'sortOrder' => $direction];
252+
$this->orders[] = ['fieldName' => $this->getMappedFieldName($column), 'sortOrder' => $direction];
284253
}
285254

286255
/**

src/Services/FileMakerConnection.php

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -30,30 +30,6 @@ class FileMakerConnection extends Connection
3030
protected $retries = 1;
3131

3232

33-
/**
34-
* Set the name of the connected database.
35-
*
36-
* @param string $connection
37-
* @return $this
38-
*/
39-
public function setConnection($connection, $config = [])
40-
{
41-
if (!$config) {
42-
$config = $this->getConnection($connection);
43-
}
44-
45-
$this->config = Arr::add($config, 'name', $connection);
46-
47-
$this->tablePrefix = $this->getConfig('prefix');
48-
49-
return $this;
50-
}
51-
52-
protected function getConnection($connection)
53-
{
54-
return config('database.connections')[$connection];
55-
}
56-
5733
/**
5834
* @param String $layout
5935
* @return $this
@@ -291,9 +267,9 @@ public function getRecords(FMBaseBuilder $query)
291267
if ($query->limit > 0) {
292268
$queryParams['_limit'] = $query->limit;
293269
}
294-
if (sizeof($query->sorts) > 0) {
270+
if ($query->orders !== null && sizeof($query->orders) > 0) {
295271
// sort can have many values, so it needs to get json_encoded and passed as a single string
296-
$queryParams['_sort'] = json_encode($query->sorts);
272+
$queryParams['_sort'] = json_encode($query->orders);
297273
}
298274

299275
$response = $this->makeRequest('get', $url, $queryParams);
@@ -446,7 +422,7 @@ protected function buildPostDataFromQuery(FMBaseBuilder $query)
446422
// attribute => parameter
447423
$params = [
448424
'wheres' => 'query',
449-
'sorts' => 'sort',
425+
'orders' => 'sort',
450426
'script' => 'script',
451427
'scriptParam' => 'script.param',
452428
'scriptPrerequest' => 'script.prerequest',

0 commit comments

Comments
 (0)