require_once "vendor/autoload.php"; use App\Models\Firestore; use Google\Cloud\Firestore\FirestoreClient; $db = new FirestoreClient([ "keyFilePath" => "Keys/carsale-f6caa-44f718f55e62.json", "projectID" => "carsale-f6caa", ]); $citiesRef = $db->collection('cars'); $firstQuery = $citiesRef->orderBy('ref'); # Get the last document from the results $documents = $firstQuery->documents(); $lastPopulation = 0; if (!isset ($_GET['page']) ) { $page = 1; } else { $page = $_GET['page']; foreach ($documents as $document) { $lastPopulation = $document['ref']; } # Construct a new query starting at this document # Note: this will not have the desired effect if multiple cities have the exact same population value $nextQuery = $citiesRef->orderBy('ref')->startAfter([$lastPopulation]); $snapshot = $nextQuery->documents(); } $makes = $citiesRef->documents(); if(isset($_POST['search'])) { $filter = trim($_POST['searchMake']); $citiesRef = $db->collection('cars'); if($filter!="Select Make") { $carsFiltered = $citiesRef->where('make', '=', $filter); $documents = $carsFiltered->documents(); }else{ $documents = $citiesRef->documents(); } } if(isset($_POST['clear'])) { $documents = $citiesRef->documents(); } ?>
We have the best on the market