Now fix aliasing and do solve all cases for alias validation also
This commit is contained in:
parent
9e0cf41e0c
commit
82b0c3d3e0
|
|
@ -95,7 +95,7 @@ class DataGridController extends Controller
|
||||||
'gt' => '>',
|
'gt' => '>',
|
||||||
'lte' => '<=',
|
'lte' => '<=',
|
||||||
'gte' => '>=',
|
'gte' => '>=',
|
||||||
'neq' => 'not =',
|
'neq' => '!=',
|
||||||
'inc_range' => '>x AND <y', //cummutative
|
'inc_range' => '>x AND <y', //cummutative
|
||||||
'exc_range' => '>=x AND <=y',
|
'exc_range' => '>=x AND <=y',
|
||||||
'not_inc_range' => 'not >x AND <y',
|
'not_inc_range' => 'not >x AND <y',
|
||||||
|
|
@ -103,18 +103,18 @@ class DataGridController extends Controller
|
||||||
];
|
];
|
||||||
|
|
||||||
DataGrid::make([
|
DataGrid::make([
|
||||||
'name' => 'posts',
|
'name' => 'authors',
|
||||||
'table' => 'authors',
|
'table' => 'authors as a',
|
||||||
'select' => 'id',
|
'select' => 'id',
|
||||||
'filterable' => [
|
'filterable' => [
|
||||||
[
|
[
|
||||||
'column' => 'id',
|
'column' => 'a.id',
|
||||||
'type' => 'integer'
|
'type' => 'integer'
|
||||||
], [
|
], [
|
||||||
'column' => 'email',
|
'column' => 'a.email',
|
||||||
'type' => 'string'
|
'type' => 'string'
|
||||||
], [
|
], [
|
||||||
'column' => 'first_name',
|
'column' => 'a.first_name',
|
||||||
'type' => 'string'
|
'type' => 'string'
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
|
@ -129,13 +129,13 @@ class DataGridController extends Controller
|
||||||
],
|
],
|
||||||
'columns' => [
|
'columns' => [
|
||||||
[
|
[
|
||||||
'name' => 'id',
|
'name' => 'a.id',
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'label' => 'Admin ID',
|
'label' => 'Admin ID',
|
||||||
'sortable' => true,
|
'sortable' => true,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => 'email',
|
'name' => 'a.email',
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'label' => 'Admin E-Mail',
|
'label' => 'Admin E-Mail',
|
||||||
'sortable' => true,
|
'sortable' => true,
|
||||||
|
|
@ -148,7 +148,7 @@ class DataGridController extends Controller
|
||||||
// 'filterable' => true,
|
// 'filterable' => true,
|
||||||
// ],
|
// ],
|
||||||
[
|
[
|
||||||
'name' => 'first_name',
|
'name' => 'a.first_name',
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'label' => 'Admin Name',
|
'label' => 'Admin Name',
|
||||||
'sortable' => true,
|
'sortable' => true,
|
||||||
|
|
|
||||||
|
|
@ -373,9 +373,11 @@ class DataGrid
|
||||||
foreach ($parsed as $key=>$value) {
|
foreach ($parsed as $key=>$value) {
|
||||||
array_push($queried_columns, $key);
|
array_push($queried_columns, $key);
|
||||||
}
|
}
|
||||||
|
$queried_columns = str_replace('_', '.', $queried_columns);
|
||||||
foreach ($filterable_columns as $fkey=>$fvalue) {
|
foreach ($filterable_columns as $fkey=>$fvalue) {
|
||||||
//determines whether column is both filterable and query string is present for it.
|
//determines whether column is both filterable and query string is present for it.
|
||||||
foreach ($queried_columns as $key=>$value) {
|
foreach ($queried_columns as $key=>$value) {
|
||||||
|
dump($fvalue, $value);
|
||||||
if ($fvalue==$value) {
|
if ($fvalue==$value) {
|
||||||
$conditions =$parsed[$value];
|
$conditions =$parsed[$value];
|
||||||
foreach ($conditions as $condition => $filter) {
|
foreach ($conditions as $condition => $filter) {
|
||||||
|
|
@ -387,26 +389,8 @@ class DataGrid
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if ($column->filterable) { //condition is required managing params from users i.e url or request
|
|
||||||
// $qr = $_SERVER['QUERY_STRING'];
|
|
||||||
// $col_name = $column->name;
|
|
||||||
// $col_name = str_replace(".", "_", $col_name);
|
|
||||||
// // dd($qr);
|
|
||||||
// dump($col_name);
|
|
||||||
// if ($columnFromfilterableRequest = $this->request->offsetGet($col_name)) {
|
|
||||||
// if ($filter = $columnFromRequest['filter']) {
|
|
||||||
// if ($condition = $columnFromRequest['condition']) {
|
|
||||||
// $this->query->where(
|
|
||||||
// $column->correctDotOnly(),
|
|
||||||
// $condition,
|
|
||||||
// $filter
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//follow a case where table is aliased and joins are not present
|
//follow a case where table is aliased and joins are not present
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -488,20 +472,15 @@ class DataGrid
|
||||||
//Run this if there are filters or sort params or range params in the urls
|
//Run this if there are filters or sort params or range params in the urls
|
||||||
$qr = $_SERVER['QUERY_STRING'];
|
$qr = $_SERVER['QUERY_STRING'];
|
||||||
$parsed;
|
$parsed;
|
||||||
//parse_url($qr, PHP_URL_QUERY)
|
|
||||||
parse_str($qr, $parsed);
|
parse_str($qr, $parsed);
|
||||||
if (!empty($parsed)) {
|
if (!empty($parsed)) {
|
||||||
dump('parsed url is not empty');
|
// dump('parsed url is not empty');
|
||||||
// $filterable_columns = [];
|
|
||||||
// foreach ($this->filterable as $on_column) {
|
|
||||||
// array_push($filterable_columns, $on_column['column']);
|
|
||||||
// }
|
|
||||||
$this->getQueryWithFilters();
|
$this->getQueryWithFilters();
|
||||||
} else {
|
} else {
|
||||||
dd('parsed url is empty');
|
$this->results = $this->query->get();
|
||||||
|
return $this->results;
|
||||||
}
|
}
|
||||||
|
|
||||||
// dump($this->query);
|
|
||||||
$this->results = $this->query->get();
|
$this->results = $this->query->get();
|
||||||
return $this->results;
|
return $this->results;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue