gearbox-solutions / eloquent-filemaker

A Model extension and Eloquent driver for Laravel connecting to FileMaker through the Data API
https://gearboxgo.com
MIT License
54 stars 16 forks source link

Response metadata missing (totalRecordCount) #59

Closed andrez89 closed 1 year ago

andrez89 commented 1 year ago

I've been looking at the docs and sources, but I cannot find hot to retrieve informations such as 'totalRecordCount' from a get records request.

Is there a way to access this information?

Smef commented 1 year ago

There are two ways:

1 - The regular Eloquent way is to use the count() function. This works fine with Eloquent FileMaker as well. Something like MyModel::count() would give you the total record count. This can work from any query just like it does with base Eloquent, so MyModel::where('my_field', 'my value')->count() works as it normally would with Laravel.

2 - The FM facade lets you do more raw-ish queries. You get the parsed JSON results back from the data API like you would from a regular data API call, from which you can read the totalRecordCount property as normal.

I'd definitely recommend option 1.