csv export

This commit is contained in:
2023-10-08 02:12:02 +03:00
parent bac0d183c9
commit 9c90f51711
2 changed files with 18 additions and 25 deletions
+7 -17
View File
@@ -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
$records = $this->query
->filter($arguments)
// ->limit($limit)
->status(explode(",", $arguments["_sys.status_in"]))
->limit(-1)
->status(explode(",", $arguments["status_in"]))
// ->skip($skip)
->sort($sort)
->childrenDepth(0)
->parentsDepth(0)
->run();
$graph = $queryResult->getQueryRecords();
$records = $graph->getRootRecords()->toArray();
} catch (SubqueryNoResultException) {
}
->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");
+3
View File
@@ -157,8 +157,11 @@ final class Query
{
$query = DB::table("records");
$query = $this->parseFilters($query);
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) {