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' => '>',
|
||||
'lte' => '<=',
|
||||
'gte' => '>=',
|
||||
'neq' => 'not =',
|
||||
'neq' => '!=',
|
||||
'inc_range' => '>x AND <y', //cummutative
|
||||
'exc_range' => '>=x AND <=y',
|
||||
'not_inc_range' => 'not >x AND <y',
|
||||
|
|
@ -103,18 +103,18 @@ class DataGridController extends Controller
|
|||
];
|
||||
|
||||
DataGrid::make([
|
||||
'name' => 'posts',
|
||||
'table' => 'authors',
|
||||
'name' => 'authors',
|
||||
'table' => 'authors as a',
|
||||
'select' => 'id',
|
||||
'filterable' => [
|
||||
[
|
||||
'column' => 'id',
|
||||
'column' => 'a.id',
|
||||
'type' => 'integer'
|
||||
], [
|
||||
'column' => 'email',
|
||||
'column' => 'a.email',
|
||||
'type' => 'string'
|
||||
], [
|
||||
'column' => 'first_name',
|
||||
'column' => 'a.first_name',
|
||||
'type' => 'string'
|
||||
]
|
||||
],
|
||||
|
|
@ -129,13 +129,13 @@ class DataGridController extends Controller
|
|||
],
|
||||
'columns' => [
|
||||
[
|
||||
'name' => 'id',
|
||||
'name' => 'a.id',
|
||||
'type' => 'string',
|
||||
'label' => 'Admin ID',
|
||||
'sortable' => true,
|
||||
],
|
||||
[
|
||||
'name' => 'email',
|
||||
'name' => 'a.email',
|
||||
'type' => 'string',
|
||||
'label' => 'Admin E-Mail',
|
||||
'sortable' => true,
|
||||
|
|
@ -148,7 +148,7 @@ class DataGridController extends Controller
|
|||
// 'filterable' => true,
|
||||
// ],
|
||||
[
|
||||
'name' => 'first_name',
|
||||
'name' => 'a.first_name',
|
||||
'type' => 'string',
|
||||
'label' => 'Admin Name',
|
||||
'sortable' => true,
|
||||
|
|
|
|||
|
|
@ -373,9 +373,11 @@ class DataGrid
|
|||
foreach ($parsed as $key=>$value) {
|
||||
array_push($queried_columns, $key);
|
||||
}
|
||||
$queried_columns = str_replace('_', '.', $queried_columns);
|
||||
foreach ($filterable_columns as $fkey=>$fvalue) {
|
||||
//determines whether column is both filterable and query string is present for it.
|
||||
foreach ($queried_columns as $key=>$value) {
|
||||
dump($fvalue, $value);
|
||||
if ($fvalue==$value) {
|
||||
$conditions =$parsed[$value];
|
||||
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
|
||||
}
|
||||
|
||||
|
|
@ -488,20 +472,15 @@ class DataGrid
|
|||
//Run this if there are filters or sort params or range params in the urls
|
||||
$qr = $_SERVER['QUERY_STRING'];
|
||||
$parsed;
|
||||
//parse_url($qr, PHP_URL_QUERY)
|
||||
parse_str($qr, $parsed);
|
||||
if (!empty($parsed)) {
|
||||
dump('parsed url is not empty');
|
||||
// $filterable_columns = [];
|
||||
// foreach ($this->filterable as $on_column) {
|
||||
// array_push($filterable_columns, $on_column['column']);
|
||||
// }
|
||||
// dump('parsed url is not empty');
|
||||
$this->getQueryWithFilters();
|
||||
} else {
|
||||
dd('parsed url is empty');
|
||||
$this->results = $this->query->get();
|
||||
return $this->results;
|
||||
}
|
||||
|
||||
// dump($this->query);
|
||||
$this->results = $this->query->get();
|
||||
return $this->results;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue