From c6cebf4760bc2c143505d19f394c1eee658e585b Mon Sep 17 00:00:00 2001 From: Michiel Vugteveen Date: Tue, 28 Sep 2021 16:01:13 +0200 Subject: [PATCH] add filter options to first() method --- src/Picqer/Financials/Exact/Query/Findable.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Picqer/Financials/Exact/Query/Findable.php b/src/Picqer/Financials/Exact/Query/Findable.php index 748dd6d6..f75c52a3 100644 --- a/src/Picqer/Financials/Exact/Query/Findable.php +++ b/src/Picqer/Financials/Exact/Query/Findable.php @@ -122,9 +122,20 @@ public function filter($filter, $expand = '', $select = '', $system_query_option * * @return \Picqer\Financials\Exact\Model|null */ - public function first() + public function first($filter = '', $expand = '', $select = '', $system_query_options = null, array $headers = []) { - $results = $this->filter('', '', '', ['$top'=> 1]); + $query_options = [ + '$top'=> 1, + ]; + + if (is_array($system_query_options)) { + // Remove this option, we only want 1 record + unset($system_query_options['$top']); + + $query_options = array_merge($query_options, $system_query_options); + } + + $results = $this->filter($filter, $expand, $select, $query_options, $headers); $result = is_array($results) && count($results) > 0 ? $results[0] : null; return $result;