@@ -296,6 +296,25 @@ public function getRecords(FMBaseBuilder $query)
296296 // default to an empty array
297297 $ queryParams = [];
298298
299+ // handle single record requests
300+ if ($ query ->getRecordId () !== null ) {
301+ $ url .= (Str::endsWith ($ url , '/ ' ) ? '' : '/ ' ) . $ query ->getRecordId ();
302+ } else {
303+ // handle pagination and sorting
304+ // these parameters are not used for single record requests
305+ if ($ query ->offset > 0 ) {
306+ // Offset is 1-indexed
307+ $ queryParams ['_offset ' ] = $ query ->offset + 1 ;
308+ }
309+ if ($ query ->limit > 0 ) {
310+ $ queryParams ['_limit ' ] = $ query ->limit ;
311+ }
312+ if ($ query ->orders !== null && count ($ query ->orders ) > 0 ) {
313+ // sort can have many values, so it needs to get json_encoded and passed as a single string
314+ $ queryParams ['_sort ' ] = json_encode ($ query ->orders );
315+ }
316+ }
317+
299318 // handle scripts
300319 if ($ query ->script !== null ) {
301320 $ queryParams ['script ' ] = $ query ->script ;
@@ -315,23 +334,13 @@ public function getRecords(FMBaseBuilder $query)
315334 if ($ query ->scriptPrerequestParam !== null ) {
316335 $ queryParams ['script.prerequest.param ' ] = $ query ->scriptPrerequestParam ;
317336 }
337+
318338 if ($ query ->layoutResponse !== null ) {
319339 $ queryParams ['layout.response ' ] = $ query ->layoutResponse ;
320340 }
321341 if ($ query ->portal !== null ) {
322342 $ queryParams ['portal ' ] = $ query ->portal ;
323343 }
324- if ($ query ->offset > 0 ) {
325- // Offset is 1-indexed
326- $ queryParams ['_offset ' ] = $ query ->offset + 1 ;
327- }
328- if ($ query ->limit > 0 ) {
329- $ queryParams ['_limit ' ] = $ query ->limit ;
330- }
331- if ($ query ->orders !== null && count ($ query ->orders ) > 0 ) {
332- // sort can have many values, so it needs to get json_encoded and passed as a single string
333- $ queryParams ['_sort ' ] = json_encode ($ query ->orders );
334- }
335344
336345 $ response = $ this ->makeRequest ('get ' , $ url , $ queryParams );
337346
0 commit comments