diff --git a/src/Http/Controller/RecordController.php b/src/Http/Controller/RecordController.php index 80c1c97..6201d27 100644 --- a/src/Http/Controller/RecordController.php +++ b/src/Http/Controller/RecordController.php @@ -107,28 +107,19 @@ class RecordController extends Controller $sort = data_get($urlParams, "sort") ?? "-_sys.updatedAt"; $filter = data_get($urlParams, "filter") ?? []; $arguments = array_merge([ - "_sys.schema" => $schema->name, - "_sys.status_in" => "draft,published", + "schema" => $schema->name, + "status_in" => "draft,published", ], $filter); - $records = []; - - try { - $queryResult = $this->query - ->filter($arguments) - // ->limit($limit) - ->status(explode(",", $arguments["_sys.status_in"])) - // ->skip($skip) - ->sort($sort) - ->childrenDepth(0) - ->parentsDepth(0) - ->run(); - - $graph = $queryResult->getQueryRecords(); - $records = $graph->getRootRecords()->toArray(); - } catch (SubqueryNoResultException) { - } + $records = $this->query + ->filter($arguments) + ->limit(-1) + ->status(explode(",", $arguments["status_in"])) + // ->skip($skip) + ->sort($sort) + ->run() + ->records; header('Content-Type: application/csv'); header('Content-Disposition: attachment; filename="' . $schemaName . '.csv";'); @@ -221,7 +212,6 @@ class RecordController extends Controller } - public function editInline(Request $request) { $rid = $request->route("rid"); @@ -250,9 +240,9 @@ class RecordController extends Controller if ($request->input("value")) { if (in_array($request->input("ui"), ["text", "date"])) { - $arguments["data.".$request->input("field") . "_regex"] = $request->input("value"); + $arguments["data." . $request->input("field") . "_regex"] = $request->input("value"); } elseif ($request->input("ui") == "number") { - $arguments["data.".$request->input("field") . "_eqnum"] = floatval($request->input("value")); + $arguments["data." . $request->input("field") . "_eqnum"] = floatval($request->input("value")); } elseif ($request->input("ui") == "date") { } } @@ -278,7 +268,7 @@ class RecordController extends Controller $recordId = $this->recordService->create( schemaName: $request->input("record.schema"), data: $request->input("record.data"), - id:$recordId ?? "", + id: $recordId ?? "", file: $request->input("record._file") ?? [], edges: $request->input("edges") ?? [], status: $request->input("record.status"), diff --git a/src/Query/Query.php b/src/Query/Query.php index 3fee1a0..c8b0476 100644 --- a/src/Query/Query.php +++ b/src/Query/Query.php @@ -157,8 +157,11 @@ final class Query { $query = DB::table("records"); $query = $this->parseFilters($query); - $query->limit($this->options->limit); - $query->offset($this->options->skip); + if($this->options->limit > 0){ + $query->limit($this->options->limit); + $query->offset($this->options->skip); + } + $query = $this->orderByQuery($query); return $query->get()->map(function ($r) {