diff --git a/packages/Webkul/Admin/src/Http/Controllers/DataGridController.php b/packages/Webkul/Admin/src/Http/Controllers/DataGridController.php index b8e9e9b13..8def9a69f 100644 --- a/packages/Webkul/Admin/src/Http/Controllers/DataGridController.php +++ b/packages/Webkul/Admin/src/Http/Controllers/DataGridController.php @@ -148,13 +148,13 @@ class DataGridController extends Controller ] ], 'join' => [ - // [ - // 'join' => 'rightjoin', - // 'table' => 'roles as r', - // 'primaryKey' => 'a.role_id', - // 'condition' => '=', - // 'secondaryKey' => 'r.id', - // ] + [ + 'join' => 'leftjoin', + 'table' => 'posts as p', + 'primaryKey' => 'a.id', + 'condition' => '=', + 'secondaryKey' => 'p.author_id', + ] ], 'columns' => [ [ @@ -171,13 +171,13 @@ class DataGridController extends Controller 'sortable' => true, 'filterable' => true ], - // [ - // 'name' => 'r.name', - // 'type' => 'string', - // 'label' => 'Role Table ID', - // 'sortable' => true, - // 'filterable' => true, - // ], + [ + 'name' => 'p.content', + 'type' => 'string', + 'label' => 'Content', + 'sortable' => true, + 'filterable' => false, + ], [ 'name' => 'a.first_name', 'type' => 'string', diff --git a/packages/Webkul/Admin/src/Http/ViewComposers/DataGrids/UserComposer.php b/packages/Webkul/Admin/src/Http/ViewComposers/DataGrids/UserComposer.php index e9ba6e236..d3eda39c2 100644 --- a/packages/Webkul/Admin/src/Http/ViewComposers/DataGrids/UserComposer.php +++ b/packages/Webkul/Admin/src/Http/ViewComposers/DataGrids/UserComposer.php @@ -37,67 +37,109 @@ class UserComposer public function compose(View $view) { $datagrid = DataGrid::make([ - 'name' => 'admin', - // 'select' => 'id', - 'table' => 'admins as a', + 'name' => 'Users', + 'table' => 'admins as u', + 'select' => 'u.id', + 'aliased' => true , //boolean to validate aliasing on the basis of this. + 'filterable' => [ + [ + 'column' => 'u.id', + 'type' => 'integer' + ], [ + 'column' => 'u.email', + 'type' => 'string' + ], [ + 'column' => 'u.name', + 'type' => 'string' + ] + ], 'join' => [ - // [ - // 'join' => 'leftjoin', - // 'table' => 'roles as r', - // 'primaryKey' => 'a.role_id', - // 'condition' => '=', - // 'secondaryKey' => 'r.id', - // ] + [ + 'join' => 'leftjoin', + 'table' => 'roles as r', + 'primaryKey' => 'u.role_id', + 'condition' => '=', + 'secondaryKey' => 'r.id', + ] ], 'columns' => [ [ - 'name' => 'a.id', + 'name' => 'u.id', 'type' => 'string', 'label' => 'Admin ID', 'sortable' => true, - 'filterable' => false, ], [ - 'name' => 'a.name', + 'name' => 'u.name', 'type' => 'string', - 'label' => 'Name', + 'label' => 'Admin Name', 'sortable' => true, - 'filterable' => false, - // will create on run time query - // 'filter' => [ - // 'function' => 'where', // orwhere - // 'condition' => ['name', '=', 'Admin'] // multiarray - // ], - 'attributes' => [ - 'class' => 'class-a class-b', - 'data-attr' => 'whatever you want', - 'onclick' => "window.alert('alert from datagrid column')" - ], - // 'wrapper' => function ($value, $object) { - // return '' . $object->name . ''; - // }, ], [ - 'name' => 'a.role_id', + 'name' => 'u.email', 'type' => 'string', - 'label' => 'Admin Role ID', + 'label' => 'Admin E-Mail', 'sortable' => true, - 'filterable' => false, ], [ - 'name' => 'a.email', + 'name' => 'r.name', 'type' => 'string', - 'label' => 'Admin Email', + 'label' => 'Content', 'sortable' => true, - 'filterable' => false, - ], - [ - 'name' => 'a.status', - 'type' => 'string', - 'label' => 'Admin Status', - 'sortable' => true, - 'filterable' => false, ], + // [ + // 'name' => 'a.first_name', + // 'type' => 'string', + // 'label' => 'Admin Name', + // 'sortable' => true, + // 'filterable' => true, + // // will create on run time query + // // 'filter' => [ + // // 'function' => 'where', // orwhere + // // 'condition' => ['name', '=', 'Admin'] // multiarray + // // ], + // 'attributes' => [ + // 'class' => 'class-a class-b', + // 'data-attr' => 'whatever you want', + // 'onclick' => "window.alert('alert from datagrid column')" + // ], + // 'wrapper' => function ($value, $object) { + // return '' . $object->first_name . ''; + // }, + // ], + + ], + 'select_verbs' => [ + 0 => "aggregate", + 1 => "columns", + 2 => "from", + 3 => "joins", + 4 => "wheres", + 5 => "groups", + 6 => "havings", + 7 => "orders", + 8 => "limit", + 9 => "offset", + 10 => "lock" + ], + 'operators' => [ + 'eq' => "=", + 'lt' => "<", + 'gt' => ">", + 'lte' => "<=", + 'gte' => ">=", + 'neqs' => "<>", + 'neqn' => "!=", + 'ceq' => "<=>", + 'like' => "like", + 'likebin' => "like binary", + 'ntlike' => "not like", + 'ilike' => "ilike", + 'regex' => "regexp", + 'notregex' => "not regexp", + 'simto' => "similar to", + 'nsimto' => "not similar to", + 'nilike' => "not ilike", ], // 'css' => [] diff --git a/packages/Webkul/Ui/src/DataGrid/DataGrid.php b/packages/Webkul/Ui/src/DataGrid/DataGrid.php index 1a2459981..21a9a9b61 100644 --- a/packages/Webkul/Ui/src/DataGrid/DataGrid.php +++ b/packages/Webkul/Ui/src/DataGrid/DataGrid.php @@ -87,8 +87,8 @@ class DataGrid public function make($args) { // list($name, $select, $table, $join, $columns) = array_values($args); - $name = $select = $filterable = $aliased = $table = false; - $join = $columns = $css = $operators = []; + $name = $select = $aliased = $table = false; + $join = $columns = $filterable = $css = $operators = []; extract($args); return $this->build($name, $select, $filterable, $aliased, $table, $join, $columns, $css, $operators); } @@ -372,7 +372,7 @@ class DataGrid private function getQueryWithFilters() { - // the only use case remaining is making and testing the full validation and testing of t\ + // the only use case remaining is making and testing the full validation and testing of // aliased case with alias used in column names also. if ($this->aliased) { //n of joins can lead to n number of aliases for columns and neglect the as for columns diff --git a/packages/Webkul/Ui/src/Resources/views/datagrid/index.blade.php b/packages/Webkul/Ui/src/Resources/views/datagrid/index.blade.php index 01d42389b..372bbc88b 100644 --- a/packages/Webkul/Ui/src/Resources/views/datagrid/index.blade.php +++ b/packages/Webkul/Ui/src/Resources/views/datagrid/index.blade.php @@ -1,6 +1,6 @@