all datagrids converted according to newly refactored pattern

This commit is contained in:
Prashant Singh 2019-01-10 11:51:45 +05:30
parent f5450cc516
commit 479341eaef
22 changed files with 1544 additions and 2322 deletions

View File

@ -2,213 +2,141 @@
namespace Webkul\Admin\DataGrids; namespace Webkul\Admin\DataGrids;
use Illuminate\View\View; use Webkul\Ui\DataGrid\AbsGrid;
use Webkul\Ui\DataGrid\Facades\DataGrid; use DB;
/** /**
* Attributes DataGrid * Product Data Grid class
* *
* @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul * @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/ */
class AttributeDataGrid class AttributeDataGrid extends AbsGrid
{ {
public $allColumns = [];
/** public function prepareQueryBuilder()
* The Data Grid implementation for Attributes
*/
public function createAttributeDataGrid()
{ {
$queryBuilder = DB::table('attributes')->select('id')->addSelect($this->columns);
return DataGrid::make([ $this->setQueryBuilder($queryBuilder);
'name' => 'Attributes', }
'table' => 'attributes',
'select' => 'id',
'perpage' => 10,
'aliased' => true,
'massoperations' => [ public function addColumns()
0 => [ {
'type' => 'delete', //all lower case will be shifted in the configuration file for better control and increased fault tolerance $this->addColumn([
'action' => route('admin.catalog.attributes.massdelete'),
'method' => 'DELETE'
]
],
'actions' => [
[
'type' => 'Edit',
'route' => 'admin.catalog.attributes.edit',
'confirm_text' => 'Do you really want to edit this record?',
'icon' => 'icon pencil-lg-icon',
], [
'type' => 'Delete',
'route' => 'admin.catalog.attributes.delete',
'confirm_text' => 'Do you really want to delete this record?',
'icon' => 'icon trash-icon',
],
],
'join' => [],
//use aliasing on secodary columns if join is performed
'columns' => [
[
'name' => 'id',
'alias' => 'attributeId',
'type' => 'number',
'label' => 'ID',
'sortable' => true,
], [
'name' => 'code',
'alias' => 'attributeCode',
'type' => 'string',
'label' => 'Code',
'sortable' => true,
], [
'name' => 'admin_name',
'alias' => 'attributeAdminName',
'type' => 'string',
'label' => 'Name',
'sortable' => true,
], [
'name' => 'type',
'alias' => 'attributeType',
'type' => 'string',
'label' => 'Type',
'sortable' => true,
], [
'name' => 'is_required',
'alias' => 'attributeIsRequired',
'type' => 'boolean',
'label' => 'Required',
'sortable' => true,
'wrapper' => function ($value) {
if($value == 0)
return "False";
else
return "True";
},
], [
'name' => 'is_unique',
'alias' => 'attributeIsUnique',
'type' => 'boolean',
'label' => 'Unique',
'sortable' => true,
'wrapper' => function ($value) {
if($value == 0)
return "False";
else
return "True";
},
], [
'name' => 'value_per_locale',
'alias' => 'attributeValuePerLocale',
'type' => 'boolean',
'label' => 'Locale based',
'sortable' => true,
'wrapper' => function ($value) {
if($value == 0)
return "False";
else
return "True";
},
], [
'name' => 'value_per_channel',
'alias' => 'attributeValuePerChannel',
'type' => 'boolean',
'label' => 'Channel based',
'sortable' => true,
'wrapper' => function ($value) {
if($value == 0)
return "False";
else
return "True";
},
]
],
'filterable' => [
[
'column' => 'id', 'column' => 'id',
'alias' => 'attributeId', 'alias' => 'attributeId',
'type' => 'number',
'label' => 'ID', 'label' => 'ID',
], [ 'type' => 'number',
'column' => 'code', 'searchable' => false,
'alias' => 'attributeCode', 'sortable' => true,
'type' => 'string', 'width' => '40px'
'label' => 'Code',
], [
'column' => 'admin_name',
'alias' => 'attributeAdminName',
'type' => 'string',
'label' => 'Name',
], [
'column' => 'type',
'alias' => 'attributeType',
'type' => 'string',
'label' => 'Type',
], [
'column' => 'is_required',
'alias' => 'attributeIsRequired',
'type' => 'boolean',
'label' => 'Required',
], [
'column' => 'is_unique',
'alias' => 'attributeIsUnique',
'type' => 'boolean',
'label' => 'Unique',
], [
'column' => 'value_per_locale',
'alias' => 'attributeValuePerLocale',
'type' => 'boolean',
'label' => 'Locale based',
], [
'column' => 'value_per_channel',
'alias' => 'attributeValuePerChannel',
'type' => 'boolean',
'label' => 'Channel based',
]
],
//don't use aliasing in case of searchables
'searchable' => [
[
'column' => 'code',
'alias' => 'attributeCode',
'type' => 'string',
], [
'column' => 'admin_name',
'alias' => 'attributeAdminName',
'type' => 'string',
], [
'column' => 'type',
'alias' => 'attributeType',
'type' => 'string',
],
],
//list of viable operators that will be used
'operators' => [
'eq' => "=",
'lt' => "<",
'gt' => ">",
'lte' => "<=",
'gte' => ">=",
'neqs' => "<>",
'neqn' => "!=",
'like' => "like",
'nlike' => "not like",
],
// 'css' => []
]); ]);
$this->addColumn([
'column' => 'code',
'alias' => 'attributeCode',
'label' => 'Code',
'type' => 'string',
'searchable' => true,
'sortable' => true,
'width' => '100px'
]);
$this->addColumn([
'column' => 'admin_name',
'alias' => 'attributeAdminName',
'label' => 'Name',
'type' => 'string',
'searchable' => true,
'sortable' => true,
'width' => '100px'
]);
$this->addColumn([
'column' => 'type',
'alias' => 'attributeType',
'label' => 'Type',
'type' => 'string',
'sortable' => true,
'searchable' => true,
'width' => '100px'
]);
$this->addColumn([
'column' => 'is_required',
'alias' => 'attributeRequired',
'label' => 'Required',
'type' => 'boolean',
'sortable' => true,
'searchable' => false,
'width' => '100px'
]);
$this->addColumn([
'column' => 'is_unique',
'alias' => 'attributeIsUnique',
'label' => 'Unique',
'type' => 'boolean',
'sortable' => true,
'searchable' => false,
'width' => '100px'
]);
$this->addColumn([
'column' => 'value_per_locale',
'alias' => 'attributeValuePerLocale',
'label' => 'Locale Based',
'type' => 'boolean',
'sortable' => true,
'searchable' => false,
'width' => '100px'
]);
$this->addColumn([
'column' => 'value_per_channel',
'alias' => 'attributeValuePerChannel',
'label' => 'Channel Based',
'type' => 'boolean',
'sortable' => true,
'searchable' => false,
'width' => '100px'
]);
}
public function prepareActions() {
$this->prepareAction([
'type' => 'Edit',
'route' => 'admin.catalog.attributes.edit',
'icon' => 'icon pencil-lg-icon'
]);
$this->prepareAction([
'type' => 'Delete',
'route' => 'admin.catalog.attributes.delete',
'icon' => 'icon trash-icon'
]);
}
public function prepareMassActions() {
$this->prepareMassAction([
'type' => 'delete',
'action' => route('admin.catalog.attributes.massdelete'),
'method' => 'DELETE'
]);
} }
public function render() public function render()
{ {
return $this->createAttributeDataGrid()->render(); $this->addColumns();
$this->prepareActions();
$this->prepareMassActions();
$this->prepareQueryBuilder();
return view('ui::testgrid.table')->with('results', ['records' => $this->getCollection(), 'columns' => $this->allColumns, 'actions' => $this->actions, 'massactions' => $this->massActions]);
} }
} }

View File

@ -2,143 +2,102 @@
namespace Webkul\Admin\DataGrids; namespace Webkul\Admin\DataGrids;
use Illuminate\View\View; use Webkul\Ui\DataGrid\AbsGrid;
use Webkul\Ui\DataGrid\Facades\DataGrid; use DB;
/** /**
* Attributes Family DataGrid * Product Data Grid class
* *
* @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul * @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/ */
class AttributeFamilyDataGrid class AttributeFamilyDataGrid extends AbsGrid
{ {
public $allColumns = [];
/** public function prepareQueryBuilder()
* The Data Grid implementation for Attribute Families
*/
public function createAttributeFamilyDataGrid()
{ {
$queryBuilder = DB::table('attribute_families')->select('id')->addSelect($this->columns);
return DataGrid::make([ $this->setQueryBuilder($queryBuilder);
'name' => 'Attribute Family', }
'table' => 'attribute_families',
'select' => 'id',
'perpage' => 10,
'aliased' => false, //use this with false as default and true in case of joins
'massoperations' =>[ public function addColumns()
// [ {
// 'route' => route('admin.datagrid.delete'), $this->addColumn([
// 'method' => 'DELETE',
// 'label' => 'Delete',
// 'type' => 'button',
// ],
],
'actions' => [
[
'type' => 'Edit',
'route' => 'admin.catalog.families.edit',
'confirm_text' => 'Do you really want to edit this record?',
'icon' => 'icon pencil-lg-icon',
], [
'type' => 'Delete',
'route' => 'admin.catalog.families.delete',
'confirm_text' => 'Do you really want to delete this record?',
'icon' => 'icon trash-icon',
],
],
'join' => [
// [
// 'join' => 'leftjoin',
// 'table' => 'roles as r',
// 'primaryKey' => 'u.role_id',
// 'condition' => '=',
// 'secondaryKey' => 'r.id',
// ]
],
//use aliasing on secodary columns if join is performed
'columns' => [
[
'name' => 'id',
'alias' => 'attributeFamilyId',
'type' => 'number',
'label' => 'ID',
'sortable' => true,
], [
'name' => 'code',
'alias' => 'attributeFamilyCode',
'type' => 'string',
'label' => 'Code',
'sortable' => true,
], [
'name' => 'name',
'alias' => 'attributeFamilyName',
'type' => 'string',
'label' => 'Name',
'sortable' => true,
],
],
'filterable' => [
[
'column' => 'id', 'column' => 'id',
'alias' => 'attributeFamilyId', 'alias' => 'attributeFamilyId',
'type' => 'number',
'label' => 'ID', 'label' => 'ID',
], [ 'type' => 'number',
'column' => 'code', 'searchable' => false,
'alias' => 'attributeFamilyCode', 'sortable' => true,
'type' => 'string', 'width' => '40px'
'label' => 'Code',
], [
'column' => 'name',
'alias' => 'attributeFamilyName',
'type' => 'string',
'label' => 'Name',
],
],
//don't use aliasing in case of searchables
'searchable' => [
[
'column' => 'name',
'type' => 'string',
'label' => 'Name',
], [
'column' => 'code',
'type' => 'string',
'label' => 'Code',
],
],
//list of viable operators that will be used
'operators' => [
'eq' => "=",
'lt' => "<",
'gt' => ">",
'lte' => "<=",
'gte' => ">=",
'neqs' => "<>",
'neqn' => "!=",
'like' => "like",
'nlike' => "not like",
],
// 'css' => []
]); ]);
$this->addColumn([
'column' => 'code',
'alias' => 'attributeFamilyCode',
'label' => 'Code',
'type' => 'string',
'searchable' => true,
'sortable' => true,
'width' => '100px'
]);
$this->addColumn([
'column' => 'name',
'alias' => 'attributeFamilyName',
'label' => 'Name',
'type' => 'string',
'searchable' => true,
'sortable' => true,
'width' => '100px'
]);
}
public function prepareActions() {
$this->prepareAction([
'type' => 'Edit',
'route' => 'admin.catalog.families.edit',
'icon' => 'icon pencil-lg-icon'
]);
$this->prepareAction([
'type' => 'Delete',
'route' => 'admin.catalog.families.delete',
// 'confirm_text' => trans('ui::app.datagrid.massaction.delete', ['resource' => 'product']),
'icon' => 'icon trash-icon'
]);
}
public function prepareMassActions() {
// $this->prepareMassAction([
// 'type' => 'delete',
// 'action' => route('admin.catalog.familites.massdelete'),
// 'method' => 'DELETE'
// ]);
// $this->prepareMassAction([
// 'type' => 'update',
// 'action' => route('admin.catalog.familites.massupdate'),
// 'method' => 'PUT',
// 'options' => [
// 0 => true,
// 1 => false,
// ]
// ]);
} }
public function render() public function render()
{ {
$this->addColumns();
return $this->createAttributeFamilyDataGrid()->render(); $this->prepareActions();
$this->prepareMassActions();
$this->prepareQueryBuilder();
return view('ui::testgrid.table')->with('results', ['records' => $this->getCollection(), 'columns' => $this->allColumns, 'actions' => $this->actions, 'massactions' => $this->massActions]);
} }
} }

View File

@ -2,176 +2,122 @@
namespace Webkul\Admin\DataGrids; namespace Webkul\Admin\DataGrids;
use Illuminate\View\View; use Webkul\Ui\DataGrid\AbsGrid;
use Webkul\Ui\DataGrid\Facades\DataGrid; use DB;
/** /**
* Category DataGrid * Product Data Grid class
* *
* @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul * @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/ */
class CategoryDataGrid class CategoryDataGrid extends AbsGrid
{ {
public $allColumns = [];
/** public function prepareQueryBuilder()
* The Data Grid implementation for category
*/
public function createCategoryDataGrid()
{ {
$queryBuilder = DB::table('categories as cat')->select('cat.id')->addSelect($this->columns)->leftJoin('category_translations as ct', 'cat.id', '=', 'ct.category_id');
return DataGrid::make([ $this->setQueryBuilder($queryBuilder);
'name' => 'Categories', }
'table' => 'categories as cat',
'select' => 'cat.id',
'perpage' => 10,
'aliased' => true, //use this with false as default and true in case of joins
'massoperations' =>[ public function addColumns()
// [ {
// 'route' => route('admin.datagrid.delete'), $this->addColumn([
// 'method' => 'DELETE',
// 'label' => 'Delete',
// 'type' => 'button',
// ]
],
'actions' => [
[
'type' => 'Edit',
'route' => 'admin.catalog.categories.edit',
'confirm_text' => 'Do you really want to edit this record?',
'icon' => 'icon pencil-lg-icon',
], [
'type' => 'Delete',
'route' => 'admin.catalog.categories.delete',
'confirm_text' => 'Do you really want to delete this record?',
'icon' => 'icon trash-icon',
]
],
'join' => [
[
'join' => 'leftjoin',
'table' => 'category_translations as ct',
'primaryKey' => 'cat.id',
'condition' => '=',
'secondaryKey' => 'ct.category_id',
'conditions' => [
'condition' => ['ct.locale', app()->getLocale()]
]
], [
'join' => 'leftjoin',
'table' => 'product_categories as pc',
'primaryKey' => 'cat.id',
'condition' => '=',
'secondaryKey' => 'pc.category_id'
]
],
//use aliasing on secodary columns if join is performed
'columns' => [
[
'name' => 'cat.id',
'alias' => 'catid',
'type' => 'number',
'label' => 'ID',
'sortable' => true,
], [
'name' => 'ct.name',
'alias' => 'catname',
'type' => 'string',
'label' => 'Name',
'sortable' => true,
], [
'name' => 'cat.position',
'alias' => 'catposition',
'type' => 'string',
'label' => 'Position',
'sortable' => true,
], [
'name' => 'cat.status',
'alias' => 'catstatus',
'type' => 'boolean',
'label' => 'Visible in Menu',
'sortable' => true,
'wrapper' => function ($value) {
if($value == 0)
return "False";
else
return "True";
},
], [
'name' => 'ct.locale',
'alias' => 'catlocale',
'type' => 'string',
'label' => 'Locale',
'sortable' => true,
// 'filter' => [
// 'function' => 'orWhere',
// 'condition' => ['ct.locale', app()->getLocale()]
// ],
]
],
'filterable' => [
[
'column' => 'cat.id', 'column' => 'cat.id',
'alias' => 'catid', 'alias' => 'catId',
'type' => 'number',
'label' => 'ID', 'label' => 'ID',
], [
'column' => 'ct.name',
'alias' => 'catname',
'type' => 'string',
'label' => 'Name',
], [
'column' => 'cat.status',
'alias' => 'catstatus',
'type' => 'boolean',
'label' => 'Visible in Menu',
],
],
//don't use aliasing in case of searchables
'searchable' => [
[
'column' => 'cat.id',
'type' => 'number', 'type' => 'number',
'label' => 'ID', 'searchable' => false,
], [ 'sortable' => true,
'column' => 'ct.name', 'width' => '40px'
'type' => 'string',
'label' => 'Name',
], [
'column' => 'cat.status',
'type' => 'string',
'label' => 'Visible in Menu',
]
],
//list of viable operators that will be used
'operators' => [
'eq' => "=",
'lt' => "<",
'gt' => ">",
'lte' => "<=",
'gte' => ">=",
'neqs' => "<>",
'neqn' => "!=",
'like' => "like",
'nlike' => "not like",
],
// 'css' => []
]); ]);
$this->addColumn([
'column' => 'ct.name',
'alias' => 'catName',
'label' => 'Name',
'type' => 'string',
'searchable' => true,
'sortable' => true,
'width' => '100px'
]);
$this->addColumn([
'column' => 'cat.position',
'alias' => 'catPosition',
'label' => 'Position',
'type' => 'string',
'searchable' => true,
'sortable' => true,
'width' => '100px'
]);
$this->addColumn([
'column' => 'cat.status',
'alias' => 'catStatus',
'label' => 'Type',
'type' => 'boolean',
'sortable' => true,
'searchable' => true,
'width' => '100px'
]);
$this->addColumn([
'column' => 'ct.locale',
'alias' => 'catLocale',
'label' => 'Locale',
'type' => 'boolean',
'sortable' => true,
'searchable' => false,
'width' => '100px'
]);
}
public function prepareActions() {
$this->prepareAction([
'type' => 'Edit',
'route' => 'admin.catalog.products.edit',
'icon' => 'icon pencil-lg-icon'
]);
$this->prepareAction([
'type' => 'Delete',
'route' => 'admin.catalog.products.delete',
'confirm_text' => trans('ui::app.datagrid.massaction.delete', ['resource' => 'product']),
'icon' => 'icon trash-icon'
]);
}
public function prepareMassActions() {
// $this->prepareMassAction([
// 'type' => 'delete',
// 'action' => route('admin.catalog.products.massdelete'),
// 'method' => 'DELETE'
// ]);
// $this->prepareMassAction([
// 'type' => 'update',
// 'action' => route('admin.catalog.products.massupdate'),
// 'method' => 'PUT',
// 'options' => [
// 0 => true,
// 1 => false,
// ]
// ]);
} }
public function render() public function render()
{ {
return $this->createCategoryDataGrid()->render(); $this->addColumns();
$this->prepareActions();
$this->prepareMassActions();
$this->prepareQueryBuilder();
return view('ui::testgrid.table')->with('results', ['records' => $this->getCollection(), 'columns' => $this->allColumns, 'actions' => $this->actions, 'massactions' => $this->massActions]);
} }
} }

View File

@ -2,157 +2,112 @@
namespace Webkul\Admin\DataGrids; namespace Webkul\Admin\DataGrids;
use Illuminate\View\View; use Webkul\Ui\DataGrid\AbsGrid;
use Webkul\Ui\DataGrid\Facades\DataGrid; use DB;
/** /**
* Channels DataGrid * Channel Data Grid class
* *
* @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul * @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/ */
class ChannelDataGrid class ChannelDataGrid extends AbsGrid
{ {
public $allColumns = [];
/** public function prepareQueryBuilder()
* The Data Grid implementation for channel
*/
public function createChannelsDataGrid()
{ {
$queryBuilder = DB::table('channels')->select('id')->addSelect($this->columns);
return DataGrid::make([ $this->setQueryBuilder($queryBuilder);
'name' => 'Channels', }
'table' => 'channels',
'select' => 'id',
'perpage' => 10,
'aliased' => false, //use this with false as default and true in case of joins
'massoperations' =>[ public function addColumns()
// [ {
// 'route' => route('admin.datagrid.delete'), $this->addColumn([
// 'method' => 'DELETE',
// 'label' => 'Delete',
// 'type' => 'button',
// ],
],
'actions' => [
[
'type' => 'Edit',
'route' => 'admin.channels.edit',
'confirm_text' => 'Do you really want to edit this record?',
'icon' => 'icon pencil-lg-icon',
], [
'type' => 'Delete',
'route' => 'admin.channels.delete',
'confirm_text' => 'Do you really want to delete this record?',
'icon' => 'icon trash-icon',
],
],
'join' => [
// [
// 'join' => 'leftjoin',
// 'table' => 'roles as r',
// 'primaryKey' => 'u.role_id',
// 'condition' => '=',
// 'secondaryKey' => 'r.id',
// ]
],
//use aliasing on secodary columns if join is performed
'columns' => [
[
'name' => 'id',
'alias' => 'channelID',
'type' => 'number',
'label' => 'ID',
'sortable' => true,
], [
'name' => 'code',
'alias' => 'channelCode',
'type' => 'string',
'label' => 'Code',
'sortable' => true,
], [
'name' => 'name',
'alias' => 'channelName',
'type' => 'string',
'label' => 'Name',
'sortable' => true,
], [
'name' => 'hostname',
'alias' => 'channelHostName',
'type' => 'string',
'label' => 'Host Name',
'sortable' => true,
],
],
//don't use aliasing in case of filters
'filterable' => [
[
'column' => 'id', 'column' => 'id',
'alias' => 'channelID', 'alias' => 'channelId',
'type' => 'number',
'label' => 'ID', 'label' => 'ID',
], [ 'type' => 'number',
'column' => 'code', 'searchable' => false,
'alias' => 'channelCode', 'sortable' => true,
'type' => 'string', 'width' => '40px'
'label' => 'Code',
], [
'column' => 'name',
'alias' => 'channelName',
'type' => 'string',
'label' => 'Name',
],
],
//don't use aliasing in case of searchables
'searchable' => [
[
'column' => 'name',
'type' => 'string',
'label' => 'Name',
], [
'column' => 'code',
'type' => 'string',
'label' => 'Code',
], [
'column' => 'hostname',
'type' => 'string',
'label' => 'Host Name',
], [
'column' => 'name',
'type' => 'string',
'label' => 'Name',
],
],
//list of viable operators that will be used
'operators' => [
'eq' => "=",
'lt' => "<",
'gt' => ">",
'lte' => "<=",
'gte' => ">=",
'neqs' => "<>",
'neqn' => "!=",
'like' => "like",
'nlike' => "not like",
],
// 'css' => []
]); ]);
$this->addColumn([
'column' => 'code',
'alias' => 'channelCode',
'label' => 'Code',
'type' => 'string',
'searchable' => true,
'sortable' => true,
'width' => '100px'
]);
$this->addColumn([
'column' => 'name',
'alias' => 'channelName',
'label' => 'Name',
'type' => 'string',
'searchable' => true,
'sortable' => true,
'width' => '100px'
]);
$this->addColumn([
'column' => 'hostname',
'alias' => 'channelHostname',
'label' => 'Hostname',
'type' => 'string',
'sortable' => true,
'searchable' => true,
'width' => '100px'
]);
}
public function prepareActions() {
$this->prepareAction([
'type' => 'Edit',
'route' => 'admin.channels.edit',
'icon' => 'icon pencil-lg-icon'
]);
$this->prepareAction([
'type' => 'Delete',
'route' => 'admin.channels.delete',
'confirm_text' => trans('ui::app.datagrid.massaction.delete', ['resource' => 'product']),
'icon' => 'icon trash-icon'
]);
}
public function prepareMassActions() {
// $this->prepareMassAction([
// 'type' => 'delete',
// 'action' => route('admin.catalog.products.massdelete'),
// 'method' => 'DELETE'
// ]);
// $this->prepareMassAction([
// 'type' => 'update',
// 'action' => route('admin.catalog.products.massupdate'),
// 'method' => 'PUT',
// 'options' => [
// 0 => true,
// 1 => false,
// ]
// ]);
} }
public function render() public function render()
{ {
return $this->createChannelsDataGrid()->render(); $this->addColumns();
$this->prepareActions();
$this->prepareMassActions();
$this->prepareQueryBuilder();
return view('ui::testgrid.table')->with('results', ['records' => $this->getCollection(), 'columns' => $this->allColumns, 'actions' => $this->actions, 'massactions' => $this->massActions]);
} }
} }

View File

@ -2,165 +2,112 @@
namespace Webkul\Admin\DataGrids; namespace Webkul\Admin\DataGrids;
use Illuminate\View\View; use Webkul\Ui\DataGrid\AbsGrid;
use Webkul\Ui\DataGrid\Facades\DataGrid; use DB;
/** /**
* Countries DataGrid * Product Data Grid class
* *
* @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul * @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/ */
class CountryDataGrid class CountryDataGrid extends AbsGrid
{ {
public $allColumns = [];
/** public function prepareQueryBuilder()
* The Data Grid implementation for countries
*/
public function createCountryDataGrid()
{ {
$queryBuilder = DB::table('countries')->select('id')->addSelect($this->columns);
return DataGrid::make([ $this->setQueryBuilder($queryBuilder);
'name' => 'Countries', }
'table' => 'countries',
'select' => 'id',
'perpage' => 10,
'aliased' => false, //use this with false as default and true in case of joins
'massoperations' =>[ public function addColumns()
// [ {
// 'route' => route('admin.datagrid.delete'), $this->addColumn([
// 'method' => 'DELETE',
// 'label' => 'Delete',
// 'type' => 'button',
// ],
],
'actions' => [
[
'type' => 'Edit',
'route' => route('admin.datagrid.delete'),
'confirm_text' => 'Do you really want to edit this record?',
'icon' => 'icon pencil-lg-icon',
], [
'type' => 'Delete',
'route' => route('admin.datagrid.delete'),
'confirm_text' => 'Do you really want to delete this record?',
'icon' => 'icon trash-icon',
],
],
'join' => [
// [
// 'join' => 'leftjoin',
// 'table' => 'roles as r',
// 'primaryKey' => 'u.role_id',
// 'condition' => '=',
// 'secondaryKey' => 'r.id',
// ]
],
//use aliasing on secodary columns if join is performed
'columns' => [
[
'name' => 'id',
'alias' => 'countryId',
'type' => 'number',
'label' => 'ID',
'sortable' => true,
], [
'name' => 'code',
'alias' => 'countryCode',
'type' => 'string',
'label' => 'Code',
'sortable' => true,
], [
'name' => 'name',
'alias' => 'countryName',
'type' => 'string',
'label' => 'Name',
'sortable' => true,
], [
'name' => 'status',
'alias' => 'countryStatus',
'type' => 'number',
'label' => 'Code',
'sortable' => true,
],
],
//don't use aliasing in case of filters
'filterable' => [
[
'column' => 'id', 'column' => 'id',
'alias' => 'countryId', 'alias' => 'countryId',
'type' => 'number',
'label' => 'ID', 'label' => 'ID',
], [
'column' => 'code',
'alias' => 'countryCode',
'type' => 'string',
'label' => 'Code',
], [
'column' => 'name',
'alias' => 'countryName',
'type' => 'string',
'label' => 'Name',
], [
'column' => 'status',
'alias' => 'countryStatus',
'type' => 'number', 'type' => 'number',
'label' => 'Code', 'searchable' => false,
], 'sortable' => true,
], 'width' => '40px'
//don't use aliasing in case of searchables
'searchable' => [
[
'column' => 'name',
'type' => 'string',
'label' => 'Name',
], [
'column' => 'code',
'type' => 'string',
'label' => 'Code',
], [
'column' => 'name',
'type' => 'string',
'label' => 'Name',
], [
'column' => 'status',
'type' => 'number',
'label' => 'Code',
]
],
//list of viable operators that will be used
'operators' => [
'eq' => "=",
'lt' => "<",
'gt' => ">",
'lte' => "<=",
'gte' => ">=",
'neqs' => "<>",
'neqn' => "!=",
'like' => "like",
'nlike' => "not like",
],
// 'css' => []
]); ]);
$this->addColumn([
'column' => 'code',
'alias' => 'countryCode',
'label' => 'Code',
'type' => 'string',
'searchable' => true,
'sortable' => true,
'width' => '100px'
]);
$this->addColumn([
'column' => 'name',
'alias' => 'countryName',
'label' => 'Name',
'type' => 'string',
'searchable' => true,
'sortable' => true,
'width' => '100px'
]);
$this->addColumn([
'column' => 'status',
'alias' => 'countryStatus',
'label' => 'Status',
'type' => 'number',
'sortable' => true,
'searchable' => true,
'width' => '100px'
]);
}
public function prepareActions() {
$this->prepareAction([
'type' => 'Edit',
'route' => 'admin.catalog.products.edit',
'icon' => 'icon pencil-lg-icon'
]);
$this->prepareAction([
'type' => 'Delete',
'route' => 'admin.catalog.products.delete',
'confirm_text' => trans('ui::app.datagrid.massaction.delete', ['resource' => 'product']),
'icon' => 'icon trash-icon'
]);
}
public function prepareMassActions() {
// $this->prepareMassAction([
// 'type' => 'delete',
// 'action' => route('admin.catalog.products.massdelete'),
// 'method' => 'DELETE'
// ]);
// $this->prepareMassAction([
// 'type' => 'update',
// 'action' => route('admin.catalog.products.massupdate'),
// 'method' => 'PUT',
// 'options' => [
// 0 => true,
// 1 => false,
// ]
// ]);
} }
public function render() public function render()
{ {
$this->addColumns();
return $this->createCountryDataGrid()->render(); $this->prepareActions();
$this->prepareMassActions();
$this->prepareQueryBuilder();
return view('ui::testgrid.table')->with('results', ['records' => $this->getCollection(), 'columns' => $this->allColumns, 'actions' => $this->actions, 'massactions' => $this->massActions]);
} }
} }

View File

@ -2,146 +2,101 @@
namespace Webkul\Admin\DataGrids; namespace Webkul\Admin\DataGrids;
use Illuminate\View\View; use Webkul\Ui\DataGrid\AbsGrid;
use Webkul\Ui\DataGrid\Facades\DataGrid; use DB;
/** /**
* Currencies DataGrid * Currency Data Grid class
* *
* @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul * @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/ */
class CurrencyDataGrid class CurrencyDataGrid extends AbsGrid
{ {
public $allColumns = [];
/** public function prepareQueryBuilder()
* The Data Grid implementation for currencies
*/
public function createCurrencyDataGrid()
{ {
$queryBuilder = DB::table('currencies')->select('id')->addSelect($this->columns);
return DataGrid::make([ $this->setQueryBuilder($queryBuilder);
'name' => 'Currencies', }
'table' => 'currencies',
'select' => 'id',
'perpage' => 10,
'aliased' => false, //use this with false as default and true in case of joins
'massoperations' =>[ public function addColumns()
0 => [ {
'type' => 'delete', //all lower case will be shifted in the configuration file for better control and increased fault tolerance $this->addColumn([
'action' => route('admin.currencies.massdelete'),
'method' => 'DELETE'
]
],
'actions' => [
[
'type' => 'Edit',
'route' => 'admin.currencies.edit',
// 'confirm_text' => 'Do you really want to edit this record?',
'icon' => 'icon pencil-lg-icon',
], [
'type' => 'Delete',
'route' => 'admin.currencies.delete',
'confirm_text' => 'Do you really want to delete this record?',
'icon' => 'icon trash-icon',
],
],
'join' => [
// [
// 'join' => 'leftjoin',
// 'table' => 'roles as r',
// 'primaryKey' => 'u.role_id',
// 'condition' => '=',
// 'secondaryKey' => 'r.id',
// ]
],
//use aliasing on secodary columns if join is performed
'columns' => [
[
'name' => 'id',
'alias' => 'currencyId',
'type' => 'number',
'label' => 'ID',
'sortable' => true,
], [
'name' => 'code',
'alias' => 'currencyCode',
'type' => 'string',
'label' => 'Code',
'sortable' => true,
], [
'name' => 'name',
'alias' => 'currencyName',
'type' => 'string',
'label' => 'Name',
'sortable' => true,
],
],
//don't use aliasing in case of filters
'filterable' => [
[
'column' => 'id', 'column' => 'id',
'alias' => 'currencyId', 'alias' => 'currencyId',
'type' => 'number',
'label' => 'ID', 'label' => 'ID',
], [
'column' => 'code',
'alias' => 'currencyCode',
'type' => 'string',
'label' => 'Code',
], [
'column' => 'name',
'alias' => 'currencyName',
'type' => 'string',
'label' => 'Name',
],
],
//don't use aliasing in case of searchables
'searchable' => [
[
'column' => 'id',
'alias' => 'currencyId',
'type' => 'number', 'type' => 'number',
], [ 'searchable' => false,
'column' => 'name', 'sortable' => true,
'type' => 'string', 'width' => '40px'
'label' => 'Name',
], [
'column' => 'code',
'type' => 'string',
'label' => 'Code',
],
],
//list of viable operators that will be used
'operators' => [
'eq' => "=",
'lt' => "<",
'gt' => ">",
'lte' => "<=",
'gte' => ">=",
'neqs' => "<>",
'neqn' => "!=",
'like' => "like",
'nlike' => "not like",
],
// 'css' => []
]); ]);
$this->addColumn([
'column' => 'name',
'alias' => 'currencyName',
'label' => 'Name',
'type' => 'string',
'searchable' => true,
'sortable' => true,
'width' => '100px'
]);
$this->addColumn([
'column' => 'code',
'alias' => 'currencyCode',
'label' => 'Code',
'type' => 'string',
'searchable' => true,
'sortable' => true,
'width' => '100px'
]);
}
public function prepareActions() {
$this->prepareAction([
'type' => 'Edit',
'route' => 'admin.currencies.edit',
'icon' => 'icon pencil-lg-icon'
]);
$this->prepareAction([
'type' => 'Delete',
'route' => 'admin.currencies.delete',
'icon' => 'icon trash-icon'
]);
}
public function prepareMassActions() {
// $this->prepareMassAction([
// 'type' => 'delete',
// 'action' => route('admin.catalog.products.massdelete'),
// 'method' => 'DELETE'
// ]);
// $this->prepareMassAction([
// 'type' => 'update',
// 'action' => route('admin.catalog.products.massupdate'),
// 'method' => 'PUT',
// 'options' => [
// 0 => true,
// 1 => false,
// ]
// ]);
} }
public function render() public function render()
{ {
return $this->createCurrencyDataGrid()->render(); $this->addColumns();
$this->prepareActions();
$this->prepareMassActions();
$this->prepareQueryBuilder();
return view('ui::testgrid.table')->with('results', ['records' => $this->getCollection(), 'columns' => $this->allColumns, 'actions' => $this->actions, 'massactions' => $this->massActions]);
} }
} }

View File

@ -2,149 +2,112 @@
namespace Webkul\Admin\DataGrids; namespace Webkul\Admin\DataGrids;
use Illuminate\View\View; use Webkul\Ui\DataGrid\AbsGrid;
use Webkul\Ui\DataGrid\Facades\DataGrid; use DB;
/** /**
* Customer DataGrid * Currency Data Grid class
* *
* @author Rahul Shukla <rahulshukla.symfony517@webkul.com> @rahul-webkul * @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/ */
class CustomerDataGrid class CustomerDataGrid extends AbsGrid
{ {
public $allColumns = [];
/** public function prepareQueryBuilder()
* The CustomerDataGrid implementation.
*/
public function createCustomerDataGrid()
{ {
$queryBuilder = DB::table('customers as cus')->select('cus.id')->addSelect($this->columns)->leftJoin('customer_groups as cg', 'cus.customer_group_id', '=', 'cg.id');
return DataGrid::make([ $this->setQueryBuilder($queryBuilder);
'name' => 'Customer', }
'table' => 'customers as cus',
'select' => 'cus.id',
'perpage' => 10,
'aliased' => true, //use this with false as default and true in case of joins
'massoperations' =>[ public function addColumns()
// [ {
// 'route' => route('admin.datagrid.delete'), $this->addColumn([
// 'method' => 'DELETE',
// 'label' => 'Delete',
// 'type' => 'button', //select || button only
// ],
],
'actions' => [
[
'type' => 'Edit',
'route' => 'admin.customer.edit',
'confirm_text' => 'Do you really want to edit this record?',
'icon' => 'icon pencil-lg-icon',
], [
'type' => 'Delete',
'route' => 'admin.customer.delete',
'confirm_text' => 'Do you really want to delete this record?',
'icon' => 'icon trash-icon',
],
],
'join' => [
[
'join' => 'leftjoin',
'table' => 'customer_groups as cg',
'primaryKey' => 'cus.customer_group_id',
'condition' => '=',
'secondaryKey' => 'cg.id',
]
],
//use aliasing on secodary columns if join is performed
'columns' => [
[
'name' => 'cus.id',
'alias' => 'ID',
'type' => 'number',
'label' => 'ID',
'sortable' => true,
], [
'name' => 'CONCAT(first_name, " ", last_name)',
'alias' => 'Name',
'type' => 'string',
'label' => 'Name',
'sortable' => true,
], [
'name' => 'email',
'alias' => 'Email',
'type' => 'string',
'label' => 'Email',
'sortable' => false,
], [
'name' => 'cg.name',
'alias' => 'CustomerGroupName',
'type' => 'string',
'label' => 'Group Name',
'sortable' => false,
],
],
//don't use aliasing in case of filters
'filterable' => [
[
'column' => 'cus.id', 'column' => 'cus.id',
'alias' => 'ID', 'alias' => 'customerId',
'type' => 'number',
'label' => 'ID', 'label' => 'ID',
], [ 'type' => 'number',
'column' => 'email', 'searchable' => false,
'alias' => 'Email', 'sortable' => true,
'type' => 'string', 'width' => '40px'
'label' => 'Email',
], [
'column' => 'cg.name',
'alias' => 'CustomerGroupName',
'type' => 'string',
'label' => 'Group Name',
]
],
//don't use aliasing in case of searchables
'searchable' => [
[
'column' => 'FirstName',
'type' => 'string',
'label' => 'First Name',
], [
'column' => 'email',
'alias' => 'Email',
'type' => 'string',
],
],
//list of viable operators that will be used
'operators' => [
'eq' => "=",
'lt' => "<",
'gt' => ">",
'lte' => "<=",
'gte' => ">=",
'neqs' => "<>",
'neqn' => "!=",
'like' => "like",
'nlike' => "not like",
],
// 'css' => []
]); ]);
$this->addColumn([
// 'column' => 'CONCAT(cus.first_name, " ", cus.last_name)',
'column' => 'cus.first_name',
'alias' => 'customerFullName',
'label' => 'Name',
'type' => 'string',
'searchable' => true,
'sortable' => true,
'width' => '100px'
]);
$this->addColumn([
'column' => 'cus.email',
'alias' => 'customerEmail',
'label' => 'Email',
'type' => 'string',
'searchable' => true,
'sortable' => true,
'width' => '100px'
]);
$this->addColumn([
'column' => 'cg.name',
'alias' => 'customerGroupName',
'label' => 'Group',
'type' => 'string',
'searchable' => false,
'sortable' => true,
'width' => '100px'
]);
} }
public function render($pagination = true) public function prepareActions() {
$this->prepareAction([
'type' => 'Edit',
'route' => 'admin.customer.edit',
'icon' => 'icon pencil-lg-icon'
]);
$this->prepareAction([
'type' => 'Delete',
'route' => 'admin.customer.delete',
'icon' => 'icon trash-icon'
]);
}
public function prepareMassActions() {
// $this->prepareMassAction([
// 'type' => 'delete',
// 'action' => route('admin.catalog.products.massdelete'),
// 'method' => 'DELETE'
// ]);
// $this->prepareMassAction([
// 'type' => 'update',
// 'action' => route('admin.catalog.products.massupdate'),
// 'method' => 'PUT',
// 'options' => [
// 0 => true,
// 1 => false,
// ]
// ]);
}
public function render()
{ {
$this->addColumns();
return $this->createCustomerDataGrid()->render($pagination); $this->prepareActions();
$this->prepareMassActions();
$this->prepareQueryBuilder();
return view('ui::testgrid.table')->with('results', ['records' => $this->getCollection(), 'columns' => $this->allColumns, 'actions' => $this->actions, 'massactions' => $this->massActions]);
} }
} }

View File

@ -2,136 +2,92 @@
namespace Webkul\Admin\DataGrids; namespace Webkul\Admin\DataGrids;
use Illuminate\View\View; use Webkul\Ui\DataGrid\AbsGrid;
use Webkul\Ui\DataGrid\Facades\DataGrid; use DB;
/** /**
* Customer Group DataGrid * Currency Data Grid class
* *
* @author Rahul Shukla <rahulshukla.symfony517@webkul.com> * @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/ */
class CustomerGroupDataGrid class CustomerGroupDataGrid extends AbsGrid
{ {
public $allColumns = [];
/** public function prepareQueryBuilder()
* The Customer Group Data Grid implementation.
*/
public function createCustomerGroupDataGrid()
{ {
$queryBuilder = DB::table('customer_groups')->select('id')->addSelect($this->columns);
return DataGrid::make([ $this->setQueryBuilder($queryBuilder);
}
'name' => 'Customer Group', public function addColumns()
'table' => 'customer_groups as cg', {
'select' => 'cg.id', $this->addColumn([
'perpage' => 10, 'column' => 'id',
'aliased' => true, //use this with false as default and true in case of joins 'alias' => 'groupId',
'massoperations' =>[
// [
// 'route' => route('admin.datagrid.delete'),
// 'method' => 'DELETE',
// 'label' => 'Delete',
// 'type' => 'button',
// ],
// [
// 'route' => route('admin.datagrid.index'),
// 'method' => 'POST',
// 'label' => 'View Grid',
// 'type' => 'select',
// 'options' =>[
// 1 => 'Edit',
// 2 => 'Set',
// 3 => 'Change Status'
// ]
// ],
],
'actions' => [
[
'type' => 'Edit',
'route' => 'admin.groups.edit',
'confirm_text' => 'Do you really want to edit this record?',
'icon' => 'icon pencil-lg-icon',
], [
'type' => 'Delete',
'route' => 'admin.groups.delete',
'confirm_text' => 'Do you really want to delete this record?',
'icon' => 'icon trash-icon',
],
],
'join' => [
// [
// 'join' => 'leftjoin',
// 'table' => 'roles as r',
// 'primaryKey' => 'u.role_id',
// 'condition' => '=',
// 'secondaryKey' => 'r.id',
// ]
],
//use aliasing on secodary columns if join is performed
'columns' => [
[
'name' => 'cg.id',
'alias' => 'ID',
'type' => 'number',
'label' => 'ID', 'label' => 'ID',
'sortable' => true,
], [
'name' => 'cg.name',
'alias' => 'Name',
'type' => 'string',
'label' => 'Name',
'sortable' => true,
],
],
//don't use aliasing in case of filters
'filterable' => [
[
'column' => 'cg.name',
'alias' => 'Name',
'type' => 'string',
'label' => 'Name'
], [
'column' => 'cg.id',
'alias' => 'ID',
'type' => 'number', 'type' => 'number',
'label' => 'ID' 'searchable' => false,
], 'sortable' => true,
], 'width' => '40px'
//don't use aliasing in case of searchables
'searchable' => [
[
'column' => 'cg.id',
'type' => 'number',
'label' => 'Id'
], [
'column' => 'cg.name',
'type' => 'string',
'label' => 'Name'
]
],
'operators' => [
'eq' => "=",
'lt' => "<",
'gt' => ">",
'lte' => "<=",
'gte' => ">=",
'neqs' => "<>",
'neqn' => "!=",
'like' => "like",
'nlike' => "not like",
],
// 'css' => []
]); ]);
$this->addColumn([
// 'column' => 'CONCAT(cus.first_name, " ", cus.last_name)',
'column' => 'name',
'alias' => 'groupName',
'label' => 'Name',
'type' => 'string',
'searchable' => true,
'sortable' => true,
'width' => '100px'
]);
} }
public function render() { public function prepareActions() {
return $this->createCustomerGroupDataGrid()->render(); $this->prepareAction([
'type' => 'Edit',
'route' => 'admin.customer.edit',
'icon' => 'icon pencil-lg-icon'
]);
$this->prepareAction([
'type' => 'Delete',
'route' => 'admin.customer.delete',
'icon' => 'icon trash-icon'
]);
}
public function prepareMassActions() {
// $this->prepareMassAction([
// 'type' => 'delete',
// 'action' => route('admin.catalog.products.massdelete'),
// 'method' => 'DELETE'
// ]);
// $this->prepareMassAction([
// 'type' => 'update',
// 'action' => route('admin.catalog.products.massupdate'),
// 'method' => 'PUT',
// 'options' => [
// 0 => true,
// 1 => false,
// ]
// ]);
}
public function render()
{
$this->addColumns();
$this->prepareActions();
$this->prepareMassActions();
$this->prepareQueryBuilder();
return view('ui::testgrid.table')->with('results', ['records' => $this->getCollection(), 'columns' => $this->allColumns, 'actions' => $this->actions, 'massactions' => $this->massActions]);
} }
} }

View File

@ -2,182 +2,121 @@
namespace Webkul\Admin\DataGrids; namespace Webkul\Admin\DataGrids;
use Illuminate\View\View; use Webkul\Ui\DataGrid\AbsGrid;
use Webkul\Ui\DataGrid\Facades\DataGrid; use DB;
/** /**
* CustomerReview DataGrid * Currency Data Grid class
* *
* @author Rahul Shukla <rahulshukla.symfony517@webkul.com> @rahul-webkul * @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/ */
class CustomerReviewDataGrid class CustomerReviewDataGrid extends AbsGrid
{ {
public $allColumns = [];
/** public function prepareQueryBuilder()
* The ProductReviewDataGrid implementation for Product Reviews
*/
public function createCustomerReviewDataGrid()
{ {
$queryBuilder = DB::table('product_reviews as pr')->select('pr.id')->addSelect($this->columns)->leftjoin('products_grid as pg', 'pr.product_id', '=', 'pg.id');
return DataGrid::make([ $this->setQueryBuilder($queryBuilder);
'name' => 'Review', }
'table' => 'product_reviews as pr',
'select' => 'pr.id',
'perpage' => 10,
'aliased' => true, //use this with false as default and true in case of joins
'massoperations' =>[ public function addColumns()
0 => [ {
'type' => 'delete', //all lower case will be shifted in the configuration file for better control and increased fault tolerance $this->addColumn([
'action' => route('admin.customer.review.massdelete'),
'method' => 'DELETE'
], 1 => [
'type' => 'update', //all lower case will be shifted in the configuration file for better control and increased fault tolerance
'action' => route('admin.customer.review.massupdate'),
'method' => 'PUT',
'options' => [
0 => 'Disapprove',
1 => 'Approve',
]
]
],
'actions' => [
[
'type' => 'Edit',
'route' => 'admin.customer.review.edit',
'confirm_text' => 'Do you really want to edit this record?',
'icon' => 'icon pencil-lg-icon',
], [
'type' => 'Delete',
'route' => 'admin.customer.review.delete',
'confirm_text' => 'Do you really want to delete this record?',
'icon' => 'icon trash-icon',
],
],
'join' => [
[
'join' => 'leftjoin',
'table' => 'products_grid as pt',
'primaryKey' => 'pr.product_id',
'condition' => '=',
'secondaryKey' => 'pt.product_id',
]
],
//use aliasing on secodary columns if join is performed
'columns' => [
[
'name' => 'pr.id',
'alias' => 'reviewId',
'type' => 'number',
'label' => 'ID',
'sortable' => true,
], [
'name' => 'pr.title',
'alias' => 'titleName',
'type' => 'string',
'label' => 'Title',
'sortable' => true,
], [
'name' => 'pr.comment',
'alias' => 'productComment',
'type' => 'string',
'label' => 'Comment',
'sortable' => true,
], [
'name' => 'pt.name',
'alias' => 'productName',
'type' => 'string',
'label' => 'Product Name',
'sortable' => true,
], [
'name' => 'pr.status',
'alias' => 'reviewStatus',
'type' => 'number',
'label' => 'Status',
'sortable' => true,
'closure' => true,
'wrapper' => function ($value) {
if($value == 'approved')
return '<span class="badge badge-md badge-success">Approved</span>';
else if($value == "pending")
return '<span class="badge badge-md badge-warning">Pending</span>';
},
],
],
//don't use aliasing in case of filters
'filterable' => [
[
'column' => 'pr.id', 'column' => 'pr.id',
'alias' => 'reviewId', 'alias' => 'reviewId',
'type' => 'number',
'label' => 'ID', 'label' => 'ID',
], [
'column' => 'pr.title',
'alias' => 'titleName',
'type' => 'string',
'label' => 'Title',
], [
'column' => 'pr.comment',
'alias' => 'productComment',
'type' => 'string',
'label' => 'Comment',
], [
'column' => 'pt.name',
'alias' => 'productName',
'type' => 'string',
'label' => 'Product Name',
], [
'column' => 'pr.status',
'alias' => 'reviewStatus',
'type' => 'string',
'label' => 'Status',
],
],
//don't use aliasing in case of searchables
'searchable' => [
[
'column' => 'title',
'type' => 'string',
'label' => 'Title',
], [
'column' => 'rating',
'type' => 'number', 'type' => 'number',
'label' => 'Rating', 'searchable' => false,
], [ 'sortable' => true,
'column' => 'pt.name', 'width' => '40px'
'alias' => 'productName',
'type' => 'string',
],
],
//list of viable operators that will be used
'operators' => [
'eq' => "=",
'lt' => "<",
'gt' => ">",
'lte' => "<=",
'gte' => ">=",
'neqs' => "<>",
'neqn' => "!=",
'like' => "like",
'nlike' => "not like",
],
// 'css' => []
]); ]);
$this->addColumn([
'column' => 'pr.title',
'alias' => 'reviewTitle',
'label' => 'Title',
'type' => 'string',
'searchable' => true,
'sortable' => true,
'width' => '100px'
]);
$this->addColumn([
'column' => 'pr.comment',
'alias' => 'reviewComment',
'label' => 'Comment',
'type' => 'string',
'searchable' => true,
'sortable' => true,
'width' => '100px'
]);
$this->addColumn([
'column' => 'pg.name',
'alias' => 'productName',
'label' => 'Product',
'type' => 'string',
'searchable' => true,
'sortable' => true,
'width' => '100px'
]);
$this->addColumn([
'column' => 'pr.status',
'alias' => 'reviewStatus',
'label' => 'Status',
'type' => 'boolean',
'searchable' => true,
'sortable' => true,
'width' => '100px'
]);
}
public function prepareActions() {
$this->prepareAction([
'type' => 'Edit',
'route' => 'admin.customer.review.edit',
'icon' => 'icon pencil-lg-icon'
]);
$this->prepareAction([
'type' => 'Delete',
'route' => 'admin.customer.review.delete',
'icon' => 'icon trash-icon'
]);
}
public function prepareMassActions() {
$this->prepareMassAction([
'type' => 'delete',
'action' => route('admin.catalog.products.massdelete'),
'method' => 'DELETE'
]);
$this->prepareMassAction([
'type' => 'update',
'action' => route('admin.catalog.products.massupdate'),
'method' => 'PUT',
'options' => [
0 => true,
1 => false,
]
]);
} }
public function render() public function render()
{ {
return $this->createCustomerReviewDataGrid()->render(); $this->addColumns();
$this->prepareActions();
$this->prepareMassActions();
$this->prepareQueryBuilder();
return view('ui::testgrid.table')->with('results', ['records' => $this->getCollection(), 'columns' => $this->allColumns, 'actions' => $this->actions, 'massactions' => $this->massActions]);
} }
} }

View File

@ -2,141 +2,102 @@
namespace Webkul\Admin\DataGrids; namespace Webkul\Admin\DataGrids;
use Illuminate\View\View; use Webkul\Ui\DataGrid\AbsGrid;
use Webkul\Ui\DataGrid\Facades\DataGrid; use DB;
/** /**
* Exchange Rates DataGrid * Product Data Grid class
* *
* @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul * @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/ */
class ExchangeRatesDataGrid class ExchangeRatesDataGrid extends AbsGrid
{ {
public $allColumns = [];
/** public function prepareQueryBuilder()
* The Data Grid implementation for Exchange Rates
*/
public function createExchangeRatesDataGrid()
{ {
$queryBuilder = DB::table('currency_exchange_rates as cer')->select('cer.id')->addSelect($this->columns)->leftJoin('currencies as curr', 'cer.target_currency', '=', 'curr.id');
return DataGrid::make([ $this->setQueryBuilder($queryBuilder);
'name' => 'Exchange Rates', }
'table' => 'currency_exchange_rates as cer',
'select' => 'cer.id',
'perpage' => 10,
'aliased' => true, //use this with false as default and true in case of joins
'massoperations' =>[ public function addColumns()
// [ {
// 'route' => route('admin.datagrid.delete'), $this->addColumn([
// 'method' => 'DELETE',
// 'label' => 'Delete',
// 'type' => 'button',
// ],
],
'actions' => [
[
'type' => 'Edit',
'route' => 'admin.exchange_rates.edit',
'confirm_text' => 'Do you really want to edit this record?',
'icon' => 'icon pencil-lg-icon',
], [
'type' => 'Delete',
'route' => 'admin.exchange_rates.delete',
'confirm_text' => 'Do you really want to delete this record?',
'icon' => 'icon trash-icon',
],
],
'join' => [
[
'join' => 'leftjoin',
'table' => 'currencies as curr',
'primaryKey' => 'cer.target_currency',
'condition' => '=',
'secondaryKey' => 'curr.id',
]
],
//use aliasing on secodary columns if join is performed
'columns' => [
[
'name' => 'cer.id',
'alias' => 'exchid',
'type' => 'number',
'label' => 'Rate ID',
'sortable' => true,
], [
'name' => 'curr.name',
'alias' => 'exchcurrname',
'type' => 'string',
'label' => 'Currency Name',
'sortable' => true,
], [
'name' => 'cer.rate',
'alias' => 'exchrate',
'type' => 'string',
'label' => 'Exchange Rate',
'sortable' => true
],
],
//don't use aliasing in case of filters
'filterable' => [
[
'column' => 'cer.id', 'column' => 'cer.id',
'alias' => 'exchid', 'alias' => 'exchId',
'label' => 'ID',
'type' => 'number', 'type' => 'number',
'label' => 'Rate ID', 'searchable' => false,
], [ 'sortable' => true,
'column' => 'curr.name', 'width' => '40px'
'alias' => 'exchcurrname',
'type' => 'string',
'label' => 'Currency Name',
], [
'column' => 'cer.rate',
'alias' => 'exchrate',
'type' => 'string',
'label' => 'Exchange Rate',
],
],
//don't use aliasing in case of searchables
'searchable' => [
[
'column' => 'exchcurrname',
'type' => 'string',
'label' => 'Currency Name',
], [
'column' => 'cer.rate',
'type' => 'string',
'label' => 'Exchange Rate',
],
],
//list of viable operators that will be used
'operators' => [
'eq' => "=",
'lt' => "<",
'gt' => ">",
'lte' => "<=",
'gte' => ">=",
'neqs' => "<>",
'neqn' => "!=",
'like' => "like",
'nlike' => "not like",
],
// 'css' => []
]); ]);
$this->addColumn([
'column' => 'curr.name',
'alias' => 'exchName',
'label' => 'Currency Name',
'type' => 'string',
'searchable' => true,
'sortable' => true,
'width' => '100px'
]);
$this->addColumn([
'column' => 'cer.rate',
'alias' => 'exchRate',
'label' => 'Exchange Rate',
'type' => 'string',
'searchable' => true,
'sortable' => true,
'width' => '100px'
]);
}
public function prepareActions() {
$this->prepareAction([
'type' => 'Edit',
'route' => 'admin.exchange_rates.edit',
'icon' => 'icon pencil-lg-icon'
]);
$this->prepareAction([
'type' => 'Delete',
'route' => 'admin.exchange_rates.delete',
'confirm_text' => trans('ui::app.datagrid.massaction.delete', ['resource' => 'Exchange Rate']),
'icon' => 'icon trash-icon'
]);
}
public function prepareMassActions() {
// $this->prepareMassAction([
// 'type' => 'delete',
// 'action' => route('admin.catalog.products.massdelete'),
// 'method' => 'DELETE'
// ]);
// $this->prepareMassAction([
// 'type' => 'update',
// 'action' => route('admin.catalog.products.massupdate'),
// 'method' => 'PUT',
// 'options' => [
// 0 => true,
// 1 => false,
// ]
// ]);
} }
public function render() public function render()
{ {
return $this->createExchangeRatesDataGrid()->render(); $this->addColumns();
$this->prepareActions();
$this->prepareMassActions();
$this->prepareQueryBuilder();
return view('ui::testgrid.table')->with('results', ['records' => $this->getCollection(), 'columns' => $this->allColumns, 'actions' => $this->actions, 'massactions' => $this->massActions]);
} }
} }

View File

@ -2,169 +2,122 @@
namespace Webkul\Admin\DataGrids; namespace Webkul\Admin\DataGrids;
use Illuminate\View\View; use Webkul\Ui\DataGrid\AbsGrid;
use Webkul\Ui\DataGrid\Facades\DataGrid; use DB;
/** /**
* Inventory Sources DataGrid * Product Data Grid class
* *
* @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul * @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/ */
class InventorySourcesDataGrid class InventorySourcesDataGrid extends AbsGrid
{ {
public $allColumns = [];
/** public function prepareQueryBuilder()
* The Data Grid implementation for Inventory Sources
*/
public function createInventorySourcesDataGrid()
{ {
return DataGrid::make([ $queryBuilder = DB::table('inventory_sources')->select('id')->addSelect($this->columns);
'name' => 'Inventory Sources',
'table' => 'inventory_sources',
'select' => 'id',
'perpage' => 10,
'aliased' => false, //use this with false as default and true in case of joins
'massoperations' =>[ $this->setQueryBuilder($queryBuilder);
// [ }
// 'route' => route('admin.datagrid.delete'),
// 'method' => 'DELETE',
// 'label' => 'Delete',
// 'type' => 'button',
// ],
],
'actions' => [ public function addColumns()
[ {
$this->addColumn([
'column' => 'id',
'alias' => 'invId',
'label' => 'ID',
'type' => 'number',
'searchable' => false,
'sortable' => true,
'width' => '40px'
]);
$this->addColumn([
'column' => 'code',
'alias' => 'invCode',
'label' => 'Code',
'type' => 'string',
'searchable' => true,
'sortable' => true,
'width' => '100px'
]);
$this->addColumn([
'column' => 'name',
'alias' => 'invName',
'label' => 'Name',
'type' => 'string',
'searchable' => true,
'sortable' => true,
'width' => '100px'
]);
$this->addColumn([
'column' => 'priority',
'alias' => 'invPriority',
'label' => 'Priority',
'type' => 'string',
'searchable' => true,
'sortable' => true,
'width' => '100px'
]);
$this->addColumn([
'column' => 'status',
'alias' => 'invStatus',
'label' => 'Status',
'type' => 'boolean',
'searchable' => true,
'sortable' => true,
'width' => '100px'
]);
}
public function prepareActions() {
$this->prepareAction([
'type' => 'Edit', 'type' => 'Edit',
'route' => 'admin.inventory_sources.edit', 'route' => 'admin.inventory_sources.edit',
'confirm_text' => 'Do you really want to edit this record?', 'icon' => 'icon pencil-lg-icon'
'icon' => 'icon pencil-lg-icon', ]);
], [
$this->prepareAction([
'type' => 'Delete', 'type' => 'Delete',
'route' => 'admin.inventory_sources.delete', 'route' => 'admin.inventory_sources.delete',
'confirm_text' => 'Do you really want to delete this record?', 'confirm_text' => trans('ui::app.datagrid.massaction.delete', ['resource' => 'Exchange Rate']),
'icon' => 'icon trash-icon', 'icon' => 'icon trash-icon'
],
],
'join' => [
// [
// 'join' => 'leftjoin',
// 'table' => 'roles as r',
// 'primaryKey' => 'u.role_id',
// 'condition' => '=',
// 'secondaryKey' => 'r.id',
// ]
],
//use aliasing on secodary columns if join is performed
'columns' => [
[
'name' => 'id',
'alias' => 'inventoryID',
'type' => 'number',
'label' => 'ID',
'sortable' => true,
], [
'name' => 'code',
'alias' => 'inventoryCode',
'type' => 'string',
'label' => 'Code',
'sortable' => true,
], [
'name' => 'name',
'alias' => 'inventoryName',
'type' => 'string',
'label' => 'Name',
'sortable' => true,
], [
'name' => 'priority',
'alias' => 'inventoryPriority',
'type' => 'string',
'label' => 'Priority',
'sortable' => true,
], [
'name' => 'status',
'alias' => 'inventoryStatus',
'type' => 'boolean',
'label' => 'Status',
'sortable' => true,
'wrapper' => function ($value) {
if($value == 0)
return "In Active";
else
return "Active";
},
],
],
//don't use aliasing in case of filters
'filterable' => [
[
'column' => 'id',
'alias' => 'inventoryID',
'type' => 'number',
'label' => 'ID',
], [
'column' => 'code',
'alias' => 'inventoryCode',
'type' => 'string',
'label' => 'Code',
], [
'column' => 'name',
'alias' => 'inventoryName',
'type' => 'string',
'label' => 'Name',
], [
'name' => 'status',
'alias' => 'inventoryStatus',
'type' => 'boolean',
'label' => 'Status',
],
],
//don't use aliasing in case of searchables
'searchable' => [
[
'column' => 'name',
'type' => 'string',
'label' => 'Name',
], [
'column' => 'code',
'type' => 'string',
'label' => 'Code',
], [
'column' => 'name',
'type' => 'string',
'label' => 'Name',
],
],
//list of viable operators that will be used
'operators' => [
'eq' => "=",
'lt' => "<",
'gt' => ">",
'lte' => "<=",
'gte' => ">=",
'neqs' => "<>",
'neqn' => "!=",
'like' => "like",
'nlike' => "not like",
],
// 'css' => []
]); ]);
} }
public function prepareMassActions() {
// $this->prepareMassAction([
// 'type' => 'delete',
// 'action' => route('admin.catalog.products.massdelete'),
// 'method' => 'DELETE'
// ]);
// $this->prepareMassAction([
// 'type' => 'update',
// 'action' => route('admin.catalog.products.massupdate'),
// 'method' => 'PUT',
// 'options' => [
// 0 => true,
// 1 => false,
// ]
// ]);
}
public function render() public function render()
{ {
return $this->createInventorySourcesDataGrid()->render(); $this->addColumns();
$this->prepareActions();
$this->prepareMassActions();
$this->prepareQueryBuilder();
return view('ui::testgrid.table')->with('results', ['records' => $this->getCollection(), 'columns' => $this->allColumns, 'actions' => $this->actions, 'massactions' => $this->massActions]);
} }
} }

View File

@ -2,141 +2,102 @@
namespace Webkul\Admin\DataGrids; namespace Webkul\Admin\DataGrids;
use Illuminate\View\View; use Webkul\Ui\DataGrid\AbsGrid;
use Webkul\Ui\DataGrid\Facades\DataGrid; use DB;
/** /**
* Locales DataGrid * Product Data Grid class
* *
* @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul * @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/ */
class LocalesDataGrid class LocalesDataGrid extends AbsGrid
{ {
public $allColumns = [];
/** public function prepareQueryBuilder()
* The Data Grid implementation for countries
*/
public function createCountryDataGrid()
{ {
$queryBuilder = DB::table('locales')->select('id')->addSelect($this->columns);
return DataGrid::make([ $this->setQueryBuilder($queryBuilder);
'name' => 'Locales', }
'table' => 'locales',
'select' => 'id',
'perpage' => 10,
'aliased' => false, //use this with false as default and true in case of joins
'massoperations' =>[ public function addColumns()
// [ {
// 'route' => route('admin.datagrid.delete'), $this->addColumn([
// 'method' => 'DELETE',
// 'label' => 'Delete',
// 'type' => 'button',
// ],
],
'actions' => [
[
'type' => 'Edit',
'route' => 'admin.locales.edit',
// 'confirm_text' => 'Do you really want to edit this record?',
'icon' => 'icon pencil-lg-icon',
], [
'type' => 'Delete',
'route' => 'admin.locales.delete',
'confirm_text' => 'Do you really want to delete this record?',
'icon' => 'icon trash-icon',
],
],
'join' => [
// [
// 'join' => 'leftjoin',
// 'table' => 'roles as r',
// 'primaryKey' => 'u.role_id',
// 'condition' => '=',
// 'secondaryKey' => 'r.id',
// ]
],
//use aliasing as attribute
'columns' => [
[
'name' => 'id',
'alias' => 'localeId',
'type' => 'number',
'label' => 'ID',
'sortable' => true,
], [
'name' => 'code',
'alias' => 'localeCode',
'type' => 'string',
'label' => 'Code',
'sortable' => true,
], [
'name' => 'name',
'alias' => 'localeName',
'type' => 'string',
'label' => 'Name',
'sortable' => true,
],
],
//don't use aliasing in case of filters
'filterable' => [
[
'column' => 'id', 'column' => 'id',
'alias' => 'localeId', 'alias' => 'localeId',
'type' => 'number',
'label' => 'ID', 'label' => 'ID',
], [ 'type' => 'number',
'column' => 'code', 'searchable' => false,
'alias' => 'localeCode', 'sortable' => true,
'type' => 'string', 'width' => '40px'
'label' => 'Code',
], [
'column' => 'name',
'alias' => 'localeName',
'type' => 'string',
'label' => 'Name',
],
],
//don't use aliasing in case of searchables
'searchable' => [
[
'column' => 'name',
'type' => 'string',
'label' => 'Name',
], [
'column' => 'code',
'type' => 'string',
'label' => 'Code',
],
],
//list of viable operators that will be used
'operators' => [
'eq' => "=",
'lt' => "<",
'gt' => ">",
'lte' => "<=",
'gte' => ">=",
'neqs' => "<>",
'neqn' => "!=",
'like' => "like",
'nlike' => "not like",
],
// 'css' => []
]); ]);
$this->addColumn([
'column' => 'code',
'alias' => 'localeCode',
'label' => 'Code',
'type' => 'string',
'searchable' => true,
'sortable' => true,
'width' => '100px'
]);
$this->addColumn([
'column' => 'name',
'alias' => 'localeName',
'label' => 'Name',
'type' => 'string',
'searchable' => true,
'sortable' => true,
'width' => '100px'
]);
}
public function prepareActions() {
$this->prepareAction([
'type' => 'Edit',
'route' => 'admin.locales.edit',
'icon' => 'icon pencil-lg-icon'
]);
$this->prepareAction([
'type' => 'Delete',
'route' => 'admin.locales.delete',
'confirm_text' => trans('ui::app.datagrid.massaction.delete', ['resource' => 'Exchange Rate']),
'icon' => 'icon trash-icon'
]);
}
public function prepareMassActions() {
// $this->prepareMassAction([
// 'type' => 'delete',
// 'action' => route('admin.catalog.products.massdelete'),
// 'method' => 'DELETE'
// ]);
// $this->prepareMassAction([
// 'type' => 'update',
// 'action' => route('admin.catalog.products.massupdate'),
// 'method' => 'PUT',
// 'options' => [
// 0 => true,
// 1 => false,
// ]
// ]);
} }
public function render() public function render()
{ {
return $this->createCountryDataGrid()->render(); $this->addColumns();
$this->prepareActions();
$this->prepareMassActions();
$this->prepareQueryBuilder();
return view('ui::testgrid.table')->with('results', ['records' => $this->getCollection(), 'columns' => $this->allColumns, 'actions' => $this->actions, 'massactions' => $this->massActions]);
} }
} }

View File

@ -2,140 +2,102 @@
namespace Webkul\Admin\DataGrids; namespace Webkul\Admin\DataGrids;
use Illuminate\View\View; use Webkul\Ui\DataGrid\AbsGrid;
use Webkul\Ui\DataGrid\Facades\DataGrid; use DB;
/** /**
* orderDataGrid * News Letter Grid class
* *
* @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul * @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/ */
class NewsLetterDataGrid class NewsLetterDataGrid extends AbsGrid
{ {
public $allColumns = [];
/** public function prepareQueryBuilder()
* The Data Grid implementation for orders
*/
public function newsLetterDataGrid()
{ {
$queryBuilder = DB::table('subscribers_list')->select('id')->addSelect($this->columns);
return DataGrid::make([ $this->setQueryBuilder($queryBuilder);
'name' => 'Subscriberslist', }
'table' => 'subscribers_list as sublist',
'select' => 'sublist.id',
'perpage' => 10,
'aliased' => false,
//True in case of joins else aliasing key required on all cases
'massoperations' =>[ public function addColumns()
// [ {
// 'route' => route('admin.datagrid.delete'), $this->addColumn([
// 'method' => 'DELETE', 'column' => 'id',
// 'label' => 'Delete', 'alias' => 'subsId',
// 'type' => 'button', 'label' => 'ID',
// ], 'type' => 'number',
], 'searchable' => false,
'sortable' => true,
'width' => '40px'
]);
'actions' => [ $this->addColumn([
[ 'column' => 'is_subscribed',
'alias' => 'subsCode',
'label' => 'Subscribed',
'type' => 'string',
'searchable' => true,
'sortable' => true,
'width' => '100px'
]);
$this->addColumn([
'column' => 'email',
'alias' => 'subsEmail',
'label' => 'Email',
'type' => 'string',
'searchable' => true,
'sortable' => true,
'width' => '100px'
]);
}
public function prepareActions() {
$this->prepareAction([
'type' => 'Edit', 'type' => 'Edit',
'route' => 'admin.customers.subscribers.edit', 'route' => 'admin.customers.subscribers.edit',
// 'confirm_text' => 'Do you really want to delete this record?', 'icon' => 'icon pencil-lg-icon'
'icon' => 'icon pencil-lg-icon', ]);
], [
$this->prepareAction([
'type' => 'Delete', 'type' => 'Delete',
'route' => 'admin.customers.subscribers.delete', 'route' => 'admin.customers.subscribers.delete',
'confirm_text' => 'Do you really want to delete this record?', 'confirm_text' => trans('ui::app.datagrid.massaction.delete', ['resource' => 'Exchange Rate']),
'icon' => 'icon trash-icon', 'icon' => 'icon trash-icon'
],
],
'join' => [],
//use aliasing on secodary columns if join is performed
'columns' => [
[
'name' => 'sublist.id',
'alias' => 'subid',
'type' => 'number',
'label' => 'ID',
'sortable' => true
], [
'name' => 'sublist.is_subscribed',
'alias' => 'issubs',
'type' => 'boolean',
'label' => 'Subscribed',
'sortable' => true,
'wrapper' => function ($value) {
if($value == 0)
return "False";
else
return "True";
},
], [
'name' => 'sublist.email',
'alias' => 'subsemail',
'type' => 'string',
'label' => 'Email',
'sortable' => true
]
],
'filterable' => [
[
'column' => 'sublist.id',
'alias' => 'subid',
'type' => 'number',
'label' => 'ID',
], [
'column' => 'sublist.is_subscribed',
'alias' => 'issubs',
'type' => 'boolean',
'label' => 'Subscribed',
], [
'column' => 'sublist.email',
'alias' => 'subsemail',
'type' => 'string',
'label' => 'Email',
]
],
//don't use aliasing in case of searchables
'searchable' => [
[
'column' => 'sublist.id',
'type' => 'number',
'label' => 'ID',
], [
'column' => 'sublist.is_subscribed',
'type' => 'string',
'label' => 'Subscribed',
], [
'column' => 'sublist.email',
'type' => 'string',
'label' => 'Email',
]
],
//list of viable operators that will be used
'operators' => [
'eq' => "=",
'lt' => "<",
'gt' => ">",
'lte' => "<=",
'gte' => ">=",
'neqs' => "<>",
'neqn' => "!=",
'like' => "like",
'nlike' => "not like",
],
// 'css' => []
]); ]);
} }
public function prepareMassActions() {
// $this->prepareMassAction([
// 'type' => 'delete',
// 'action' => route('admin.catalog.products.massdelete'),
// 'method' => 'DELETE'
// ]);
// $this->prepareMassAction([
// 'type' => 'update',
// 'action' => route('admin.catalog.products.massupdate'),
// 'method' => 'PUT',
// 'options' => [
// 0 => true,
// 1 => false,
// ]
// ]);
}
public function render() public function render()
{ {
return $this->newsLetterDataGrid()->render(); $this->addColumns();
$this->prepareActions();
$this->prepareMassActions();
$this->prepareQueryBuilder();
return view('ui::testgrid.table')->with('results', ['records' => $this->getCollection(), 'columns' => $this->allColumns, 'actions' => $this->actions, 'massactions' => $this->massActions]);
} }
} }

View File

@ -2,137 +2,95 @@
namespace Webkul\Admin\DataGrids; namespace Webkul\Admin\DataGrids;
use Illuminate\View\View; use Webkul\Ui\DataGrid\AbsGrid;
use Webkul\Ui\DataGrid\Facades\DataGrid; use DB;
/** /**
* User Roles DataGrid * News Letter Grid class
* *
* @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul * @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/ */
class RolesDataGrid class RolesDataGrid extends AbsGrid
{ {
/** public $allColumns = [];
* The Data Grid implementation for Roles
*/ public function prepareQueryBuilder()
public function createRolesDataGrid()
{ {
$queryBuilder = DB::table('roles')->select('id')->addSelect($this->columns);
return DataGrid::make([ $this->setQueryBuilder($queryBuilder);
'name' => 'Roles', }
'table' => 'roles',
'select' => 'id',
'perpage' => 10,
'aliased' => false, //use this with false as default and true in case of joins
'massoperations' =>[ public function addColumns()
// [ {
// 'route' => route('admin.datagrid.delete'), $this->addColumn([
// 'method' => 'DELETE',
// 'label' => 'Delete',
// 'type' => 'button',
// ],
],
'actions' => [
[
'type' => 'Edit',
'route' => 'admin.roles.edit',
'confirm_text' => 'Do you really want to edit this record?',
'icon' => 'icon pencil-lg-icon',
]
],
'join' => [
// [
// 'join' => 'leftjoin',
// 'table' => 'roles as r',
// 'primaryKey' => 'u.role_id',
// 'condition' => '=',
// 'secondaryKey' => 'r.id',
// ]
],
//use aliasing on secodary columns if join is performed
'columns' => [
[
'name' => 'id',
'alias' => 'roleId',
'type' => 'number',
'label' => 'ID',
'sortable' => true,
], [
'name' => 'name',
'alias' => 'roleName',
'type' => 'string',
'label' => 'Name',
'sortable' => true,
], [
'name' => 'permission_type',
'alias' => 'rolePermissionType',
'type' => 'string',
'label' => 'Permission Type',
'sortable' => true,
],
],
//don't use aliasing in case of filters
'filterable' => [
[
'column' => 'id', 'column' => 'id',
'alias' => 'roleId', 'alias' => 'roleId',
'type' => 'number',
'label' => 'ID', 'label' => 'ID',
], [ 'type' => 'number',
'column' => 'name', 'searchable' => false,
'alias' => 'roleName', 'sortable' => true,
'type' => 'string', 'width' => '40px'
'label' => 'Name',
], [
'column' => 'permission_type',
'alias' => 'rolePermissionType',
'type' => 'string',
'label' => 'Permission Type',
],
],
//don't use aliasing in case of searchables
'searchable' => [
[
'column' => 'name',
'type' => 'string',
'label' => 'Name',
], [
'column' => 'permission_type',
'type' => 'string',
'label' => 'Permission Type',
],
],
//list of viable operators that will be used
'operators' => [
'eq' => "=",
'lt' => "<",
'gt' => ">",
'lte' => "<=",
'gte' => ">=",
'neqs' => "<>",
'neqn' => "!=",
'like' => "like",
'nlike' => "not like",
],
// 'css' => []
]); ]);
$this->addColumn([
'column' => 'name',
'alias' => 'roleName',
'label' => 'Name',
'type' => 'string',
'searchable' => true,
'sortable' => true,
'width' => '100px'
]);
$this->addColumn([
'column' => 'permission_type',
'alias' => 'roleType',
'label' => 'Permission Type',
'type' => 'string',
'searchable' => true,
'sortable' => true,
'width' => '100px'
]);
}
public function prepareActions() {
$this->prepareAction([
'type' => 'Edit',
'route' => 'admin.roles.edit',
'icon' => 'icon pencil-lg-icon'
]);
}
public function prepareMassActions() {
// $this->prepareMassAction([
// 'type' => 'delete',
// 'action' => route('admin.catalog.products.massdelete'),
// 'method' => 'DELETE'
// ]);
// $this->prepareMassAction([
// 'type' => 'update',
// 'action' => route('admin.catalog.products.massupdate'),
// 'method' => 'PUT',
// 'options' => [
// 0 => true,
// 1 => false,
// ]
// ]);
} }
public function render() public function render()
{ {
return $this->createRolesDataGrid()->render(); $this->addColumns();
$this->prepareActions();
$this->prepareMassActions();
$this->prepareQueryBuilder();
return view('ui::testgrid.table')->with('results', ['records' => $this->getCollection(), 'columns' => $this->allColumns, 'actions' => $this->actions, 'massactions' => $this->massActions]);
} }
} }

View File

@ -2,143 +2,101 @@
namespace Webkul\Admin\DataGrids; namespace Webkul\Admin\DataGrids;
use Illuminate\View\View; use Webkul\Ui\DataGrid\AbsGrid;
use Webkul\Ui\DataGrid\Facades\DataGrid; use DB;
/** /**
* Sliders DataGrid * News Letter Grid class
* *
* @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul * @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/ */
class SliderDataGrid class SliderDataGrid extends AbsGrid
{ {
public $allColumns = [];
/** public function prepareQueryBuilder()
* The Data Grid implementation for Sliders
*/
public function createSliderDataGrid()
{ {
$queryBuilder = DB::table('sliders as sl')->select('sl.id')->addSelect($this->columns)->leftJoin('channels as ch', 'sl.channel_id', '=', 'ch.id');
return DataGrid::make([ $this->setQueryBuilder($queryBuilder);
'name' => 'Sliders', }
'table' => 'sliders as s',
'select' => 's.id',
'perpage' => 10,
'aliased' => true, //use this with false as default and true in case of joins
'massoperations' =>[ public function addColumns()
// [ {
// 'route' => route('admin.datagrid.delete'), $this->addColumn([
// 'method' => 'DELETE', 'column' => 'sl.id',
// 'label' => 'Delete', 'alias' => 'sliderId',
// 'type' => 'button', 'label' => 'ID',
// ], 'type' => 'number',
], 'searchable' => false,
'sortable' => true,
'width' => '40px'
]);
'actions' => [ $this->addColumn([
[ 'column' => 'sl.title',
'alias' => 'sliderTitle',
'label' => 'Tile',
'type' => 'string',
'searchable' => true,
'sortable' => true,
'width' => '100px'
]);
$this->addColumn([
'column' => 'ch.name',
'alias' => 'channelName',
'label' => 'Channel Name',
'type' => 'string',
'searchable' => true,
'sortable' => true,
'width' => '100px'
]);
}
public function prepareActions() {
$this->prepareAction([
'type' => 'Edit', 'type' => 'Edit',
'route' => 'admin.sliders.edit', 'route' => 'admin.sliders.edit',
'confirm_text' => 'Do you really want to edit this record?', 'icon' => 'icon pencil-lg-icon'
'icon' => 'icon pencil-lg-icon', ]);
], [
$this->prepareAction([
'type' => 'Delete', 'type' => 'Delete',
'route' => 'admin.sliders.delete', 'route' => 'admin.sliders.delete',
'confirm_text' => 'Do you really want to delete this record?', 'icon' => 'icon trash-icon'
'icon' => 'icon trash-icon',
],
],
'join' => [
[
'join' => 'leftjoin',
'table' => 'channels as c',
'primaryKey' => 's.channel_id',
'condition' => '=',
'secondaryKey' => 'c.id',
]
],
//use aliasing on secodary columns if join is performed
'columns' => [
[
'name' => 's.id',
'alias' => 'sliderId',
'type' => 'number',
'label' => 'ID',
'sortable' => true,
], [
'name' => 's.title',
'alias' => 'sliderTitle',
'type' => 'string',
'label' => 'title',
'sortable' => true
], [
'name' => 'c.name',
'alias' => 'channelName',
'type' => 'string',
'label' => 'Channel Name',
'sortable' => true,
],
],
//don't use aliasing in case of filters
'filterable' => [
[
'column' => 's.id',
'alias' => 'sliderId',
'type' => 'number',
'label' => 'ID'
], [
'column' => 's.title',
'alias' => 'sliderTitle',
'type' => 'string',
'label' => 'title'
], [
'column' => 'c.name',
'alias' => 'channelName',
'type' => 'string',
'label' => 'Channel Name',
]
],
//don't use aliasing in case of searchables
'searchable' => [
[
'column' => 's.id',
'type' => 'number',
'label' => 'ID'
], [
'column' => 's.title',
'type' => 'string',
'label' => 'Slider Title'
], [
'column' => 'c.name',
'type' => 'string',
'label' => 'Channel Name',
]
],
//list of viable operators that will be used
'operators' => [
'eq' => "=",
'lt' => "<",
'gt' => ">",
'lte' => "<=",
'gte' => ">=",
'neqs' => "<>",
'neqn' => "!=",
'like' => "like",
'nlike' => "not like",
],
// 'css' => []
]); ]);
} }
public function prepareMassActions() {
// $this->prepareMassAction([
// 'type' => 'delete',
// 'action' => route('admin.catalog.products.massdelete'),
// 'method' => 'DELETE'
// ]);
// $this->prepareMassAction([
// 'type' => 'update',
// 'action' => route('admin.catalog.products.massupdate'),
// 'method' => 'PUT',
// 'options' => [
// 0 => true,
// 1 => false,
// ]
// ]);
}
public function render() public function render()
{ {
return $this->createSliderDataGrid()->render(); $this->addColumns();
$this->prepareActions();
$this->prepareMassActions();
$this->prepareQueryBuilder();
return view('ui::testgrid.table')->with('results', ['records' => $this->getCollection(), 'columns' => $this->allColumns, 'actions' => $this->actions, 'massactions' => $this->massActions]);
} }
} }

View File

@ -2,151 +2,101 @@
namespace Webkul\Admin\DataGrids; namespace Webkul\Admin\DataGrids;
use Illuminate\View\View; use Webkul\Ui\DataGrid\AbsGrid;
use Webkul\Ui\DataGrid\Facades\DataGrid; use DB;
/** /**
* Tax Category DataGrid * Tax Category Grid class
* *
* @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul * @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/ */
class TaxCategoryDataGrid extends AbsGrid
class TaxCategoryDataGrid
{ {
public $allColumns = [];
/** public function prepareQueryBuilder()
* The Tax Category Data Grid implementation.
*/
public function createTaxCategoryDataGrid()
{ {
$queryBuilder = DB::table('tax_categories as tr')->select('tr.id')->addSelect($this->columns);
return DataGrid::make([ $this->setQueryBuilder($queryBuilder);
}
'name' => 'Tax Category', public function addColumns()
'table' => 'tax_categories as tr', {
'select' => 'tr.id', $this->addColumn([
'perpage' => 10,
'aliased' => true, //use this with false as default and true in case of joins
'massoperations' =>[
// [
// 'route' => route('admin.datagrid.delete'),
// 'method' => 'DELETE',
// 'label' => 'Delete',
// 'type' => 'button',
// ],
// [
// 'route' => route('admin.datagrid.index'),
// 'method' => 'POST',
// 'label' => 'View Grid',
// 'type' => 'select',
// 'options' =>[
// 1 => 'Edit',
// 2 => 'Set',
// 3 => 'Change Status'
// ]
// ],
],
'actions' => [
[
'type' => 'Edit',
'route' => 'admin.tax-categories.edit',
'confirm_text' => 'Do you really want to edit this record?',
'icon' => 'icon pencil-lg-icon',
],
[
'type' => 'Delete',
'route' => 'admin.tax-categories.delete',
'confirm_text' => 'Do you really want to delete this record?',
'icon' => 'icon trash-icon',
],
],
'join' => [
// [
// 'join' => 'leftjoin',
// 'table' => 'roles as r',
// 'primaryKey' => 'u.role_id',
// 'condition' => '=',
// 'secondaryKey' => 'r.id',
// ]
],
//use aliasing on secodary columns if join is performed
'columns' => [
[
'name' => 'tr.id',
'alias' => 'ID',
'type' => 'number',
'label' => 'ID',
'sortable' => true,
], [
'name' => 'tr.name',
'alias' => 'Name',
'type' => 'string',
'label' => 'Name',
'sortable' => true,
], [
'name' => 'tr.code',
'alias' => 'code',
'type' => 'string',
'label' => 'Code',
'sortable' => true,
],
],
//don't use aliasing in case of filters
'filterable' => [
[
'column' => 'tr.id', 'column' => 'tr.id',
'alias' => 'ID', 'alias' => 'taxCatId',
'label' => 'ID',
'type' => 'number', 'type' => 'number',
'label' => 'ID' 'searchable' => false,
], [ 'sortable' => true,
'column' => 'tr.name', 'width' => '40px'
'alias' => 'Name',
'type' => 'string',
'label' => 'Name'
], [
'column' => 'tr.code',
'alias' => 'code',
'type' => 'string',
'label' => 'Code'
]
],
//don't use aliasing in case of searchables
'searchable' => [
[
'column' => 'tr.code',
'type' => 'string',
'label' => 'Code'
], [
'column' => 'tr.name',
'type' => 'string',
'label' => 'Name'
]
],
'operators' => [
'eq' => "=",
'lt' => "<",
'gt' => ">",
'lte' => "<=",
'gte' => ">=",
'neqs' => "<>",
'neqn' => "!=",
'like' => "like",
'nlike' => "not like",
],
// 'css' => []
]); ]);
$this->addColumn([
'column' => 'tr.name',
'alias' => 'taxCatName',
'label' => 'Name',
'type' => 'string',
'searchable' => true,
'sortable' => true,
'width' => '100px'
]);
$this->addColumn([
'column' => 'tr.code',
'alias' => 'taxCatCode',
'label' => 'Code',
'type' => 'string',
'searchable' => true,
'sortable' => true,
'width' => '100px'
]);
} }
public function render() { public function prepareActions() {
$this->prepareAction([
'type' => 'Edit',
'route' => 'admin.tax-categories.edit',
'icon' => 'icon pencil-lg-icon'
]);
return $this->createTaxCategoryDataGrid()->render(); $this->prepareAction([
'type' => 'Delete',
'route' => 'admin.tax-categories.delete',
'icon' => 'icon trash-icon'
]);
}
public function prepareMassActions() {
// $this->prepareMassAction([
// 'type' => 'delete',
// 'action' => route('admin.catalog.products.massdelete'),
// 'method' => 'DELETE'
// ]);
// $this->prepareMassAction([
// 'type' => 'update',
// 'action' => route('admin.catalog.products.massupdate'),
// 'method' => 'PUT',
// 'options' => [
// 0 => true,
// 1 => false,
// ]
// ]);
}
public function render()
{
$this->addColumns();
$this->prepareActions();
$this->prepareMassActions();
$this->prepareQueryBuilder();
return view('ui::testgrid.table')->with('results', ['records' => $this->getCollection(), 'columns' => $this->allColumns, 'actions' => $this->actions, 'massactions' => $this->massActions]);
} }
} }

View File

@ -2,172 +2,121 @@
namespace Webkul\Admin\DataGrids; namespace Webkul\Admin\DataGrids;
use Illuminate\View\View; use Webkul\Ui\DataGrid\AbsGrid;
use Webkul\Ui\DataGrid\Facades\DataGrid; use DB;
/** /**
* Tax Rates DataGrid * Tax Rate Grid class
* *
* @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul * @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/ */
class TaxRateDataGrid class TaxRateDataGrid extends AbsGrid
{ {
public $allColumns = [];
/** public function prepareQueryBuilder()
* The Tax Category Data Grid implementation.
*/
public function createTaxRateDataGrid()
{ {
$queryBuilder = DB::table('tax_rates as tr')->select('tr.id')->addSelect($this->columns);
return DataGrid::make([ $this->setQueryBuilder($queryBuilder);
'name' => 'Tax Rates', }
'table' => 'tax_rates as tr',
'select' => 'tr.id',
'perpage' => 10,
'aliased' => true, //use this with false as default and true in case of joins
'massoperations' =>[ public function addColumns()
// [ {
// 'route' => route('admin.datagrid.delete'), $this->addColumn([
// 'method' => 'DELETE',
// 'label' => 'Delete',
// 'type' => 'button',
// ],
// [
// 'route' => route('admin.datagrid.index'),
// 'method' => 'POST',
// 'label' => 'View Grid',
// 'type' => 'select',
// 'options' =>[
// 1 => 'Edit',
// 2 => 'Set',
// 3 => 'Change Status'
// ]
// ],
],
'actions' => [
[
'type' => 'Edit',
'route' => 'admin.tax-rates.store',
'confirm_text' => 'Do you really want to edit this record?',
'icon' => 'icon pencil-lg-icon',
],
[
'type' => 'Delete',
'route' => 'admin.tax-rates.delete',
'confirm_text' => 'Do you really want to delete this record?',
'icon' => 'icon trash-icon',
],
],
'join' => [],
//use aliasing on secodary columns if join is performed
'columns' => [
[
'name' => 'tr.id',
'alias' => 'id',
'type' => 'number',
'label' => 'ID',
'sortable' => true,
], [
'name' => 'tr.identifier',
'alias' => 'identifier',
'type' => 'string',
'label' => 'Identifier',
'sortable' => true,
// 'wrapper' => function ($value, $object) {
// return '<a class="color-red">' . $object->identifier . '</a>';
// },
], [
'name' => 'tr.state',
'alias' => 'state',
'type' => 'string',
'label' => 'State',
'sortable' => true,
], [
'name' => 'tr.country',
'alias' => 'country',
'type' => 'string',
'label' => 'Country',
'sortable' => true,
], [
'name' => 'tr.tax_rate',
'alias' => 'taxrate',
'type' => 'number',
'label' => 'Tax Rate',
'sortable' => true,
],
],
//don't use aliasing in case of filters
'filterable' => [
[
'column' => 'tr.id', 'column' => 'tr.id',
'alias' => 'ID', 'alias' => 'taxRateId',
'type' => 'number',
'label' => 'ID', 'label' => 'ID',
], [
'column' => 'tr.identifier',
'alias' => 'identifier',
'type' => 'string',
'label' => 'Identifier',
], [
'column' => 'tr.state',
'alias' => 'state',
'type' => 'string',
'label' => 'State',
], [
'column' => 'tr.country',
'alias' => 'country',
'type' => 'string',
'label' => 'Country',
], [
'column' => 'tr.tax_rate',
'alias' => 'taxrate',
'type' => 'number', 'type' => 'number',
'label' => 'Tax Rate', 'searchable' => false,
], 'sortable' => true,
], 'width' => '40px'
//don't use aliasing in case of searchables
'searchable' => [
[
'column' => 'tr.identifier',
'type' => 'string',
'label' => 'Identifier',
], [
'column' => 'tr.state',
'type' => 'string',
'label' => 'State',
], [
'column' => 'tr.country',
'type' => 'string',
'label' => 'Country',
], [
'column' => 'tr.tax_rate',
'type' => 'number',
'label' => 'Tax Rate',
],
],
'operators' => [
'eq' => "=",
'lt' => "<",
'gt' => ">",
'lte' => "<=",
'gte' => ">=",
'neqs' => "<>",
'neqn' => "!=",
'like' => "like",
'nlike' => "not like",
],
// 'css' => []
]); ]);
$this->addColumn([
'column' => 'tr.identifier',
'alias' => 'taxRateName',
'label' => 'Identifier',
'type' => 'string',
'searchable' => true,
'sortable' => true,
'width' => '100px'
]);
$this->addColumn([
'column' => 'tr.state',
'alias' => 'taxRateState',
'label' => 'State',
'type' => 'string',
'searchable' => true,
'sortable' => true,
'width' => '100px'
]);
$this->addColumn([
'column' => 'tr.country',
'alias' => 'taxRateCountry',
'label' => 'Country',
'type' => 'string',
'searchable' => true,
'sortable' => true,
'width' => '100px'
]);
$this->addColumn([
'column' => 'tr.tax_rate',
'alias' => 'taxRate',
'label' => 'Rate',
'type' => 'string',
'searchable' => true,
'sortable' => true,
'width' => '100px'
]);
} }
public function render() { public function prepareActions() {
$this->prepareAction([
'type' => 'Edit',
'route' => 'admin.tax-categories.edit',
'icon' => 'icon pencil-lg-icon'
]);
return $this->createTaxRateDataGrid()->render(); $this->prepareAction([
'type' => 'Delete',
'route' => 'admin.tax-categories.delete',
'icon' => 'icon trash-icon'
]);
}
public function prepareMassActions() {
// $this->prepareMassAction([
// 'type' => 'delete',
// 'action' => route('admin.catalog.products.massdelete'),
// 'method' => 'DELETE'
// ]);
// $this->prepareMassAction([
// 'type' => 'update',
// 'action' => route('admin.catalog.products.massupdate'),
// 'method' => 'PUT',
// 'options' => [
// 0 => true,
// 1 => false,
// ]
// ]);
}
public function render()
{
$this->addColumns();
$this->prepareActions();
$this->prepareMassActions();
$this->prepareQueryBuilder();
return view('ui::testgrid.table')->with('results', ['records' => $this->getCollection(), 'columns' => $this->allColumns, 'actions' => $this->actions, 'massactions' => $this->massActions]);
} }
} }

View File

@ -70,7 +70,7 @@ class TestDataGrid extends AbsGrid
'label' => 'Status', 'label' => 'Status',
'type' => 'boolean', 'type' => 'boolean',
'sortable' => true, 'sortable' => true,
'searchable' => true, 'searchable' => false,
'width' => '100px' 'width' => '100px'
]); ]);
@ -80,7 +80,7 @@ class TestDataGrid extends AbsGrid
'label' => 'Price', 'label' => 'Price',
'type' => 'number', 'type' => 'number',
'sortable' => true, 'sortable' => true,
'searchable' => true, 'searchable' => false,
'width' => '100px' 'width' => '100px'
]); ]);
@ -90,7 +90,7 @@ class TestDataGrid extends AbsGrid
'label' => 'Quantity', 'label' => 'Quantity',
'type' => 'number', 'type' => 'number',
'sortable' => true, 'sortable' => true,
'searchable' => true, 'searchable' => false,
'width' => '100px' 'width' => '100px'
]); ]);
} }

View File

@ -22,7 +22,7 @@
{{-- @inject('product','Webkul\Admin\DataGrids\ProductDataGrid') {{-- @inject('product','Webkul\Admin\DataGrids\ProductDataGrid')
{!! $product->render() !!} --}} {!! $product->render() !!} --}}
@inject('products','Webkul\Admin\DataGrids\TestDataGrid') @inject('products', 'Webkul\Admin\DataGrids\TestDataGrid')
{!! $products->render() !!} {!! $products->render() !!}
</div> </div>
</div> </div>

View File

@ -12,12 +12,12 @@
<h1>{{ __('admin::app.customers.customers.title') }}</h1> <h1>{{ __('admin::app.customers.customers.title') }}</h1>
</div> </div>
<div class="page-action"> <div class="page-action">
<div class="export" @click="showModal('downloadDataGrid')"> {{-- <div class="export" @click="showModal('downloadDataGrid')">
<i class="export-icon"></i> <i class="export-icon"></i>
<span > <span >
{{ __('admin::app.export.export') }} {{ __('admin::app.export.export') }}
</span> </span>
</div> </div> --}}
<a href="{{ route('admin.customer.create') }}" class="btn btn-lg btn-primary"> <a href="{{ route('admin.customer.create') }}" class="btn btn-lg btn-primary">
{{ __('admin::app.customers.customers.add-title') }} {{ __('admin::app.customers.customers.add-title') }}
@ -32,18 +32,18 @@
</div> </div>
</div> </div>
<modal id="downloadDataGrid" :is-open="modalIds.downloadDataGrid"> {{-- <modal id="downloadDataGrid" :is-open="modalIds.downloadDataGrid">
<h3 slot="header">{{ __('admin::app.export.download') }}</h3> <h3 slot="header">{{ __('admin::app.export.download') }}</h3>
<div slot="body"> <div slot="body">
<export-form></export-form> <export-form></export-form>
</div> </div>
</modal> </modal> --}}
@stop @stop
@push('scripts') @push('scripts')
<script type="text/x-template" id="export-form-template"> {{-- <script type="text/x-template" id="export-form-template">
<form method="POST" action="{{ route('admin.datagrid.export') }}"> <form method="POST" action="{{ route('admin.datagrid.export') }}">
<div class="page-content"> <div class="page-content">
@ -81,7 +81,7 @@
} }
} }
}); });
</script> </script> --}}
@endpush @endpush

View File

@ -91,8 +91,14 @@ abstract class AbsGrid
if(count($p)) { if(count($p)) {
$filteredOrSortedCollection = $this->sortOrFilterCollection($this->collection = $this->queryBuilder, $p); $filteredOrSortedCollection = $this->sortOrFilterCollection($this->collection = $this->queryBuilder, $p);
// return $filteredOrSortedCollection->get();
if (config()->has('datagrid.pagination')) {
return $filteredOrSortedCollection->paginate(config('datagrid.pagination'));
} else {
return $filteredOrSortedCollection->get(); return $filteredOrSortedCollection->get();
} }
}
if (config()->has('datagrid.pagination')) { if (config()->has('datagrid.pagination')) {
$this->collection = $this->queryBuilder->paginate(config('datagrid.pagination')); $this->collection = $this->queryBuilder->paginate(config('datagrid.pagination'));

View File

@ -1,6 +1,10 @@
<div class="table"> <div class="table">
<testgrid-filters></testgrid-filters> <testgrid-filters></testgrid-filters>
@if(config('datagrid.pagination'))
@include('ui::testgrid.pagination', ['results' => $results['records']])
@endif
@push('scripts') @push('scripts')
<script type="text/x-template" id="testgrid-filters"> <script type="text/x-template" id="testgrid-filters">
{{-- start filter here --}} {{-- start filter here --}}
@ -581,16 +585,28 @@
this.massActionsToggle = true; this.massActionsToggle = true;
if (this.allSelected) { if (this.allSelected) {
for (currentData in this.gridCurrentData) { if(this.gridCurrentData.hasOwnProperty("data")) {
i = 0; for (currentData in this.gridCurrentData.data) {
i = 0;
for(currentId in this.gridCurrentData.data[currentData]) {
if(i==0)
this.dataIds.push(this.gridCurrentData.data[currentData][currentId]);
i++;
}
}
} else {
for (currentData in this.gridCurrentData) {
i = 0;
for(currentId in this.gridCurrentData[currentData]) { for(currentId in this.gridCurrentData[currentData]) {
if(i==0) if(i==0)
this.dataIds.push(this.gridCurrentData[currentData][currentId]); this.dataIds.push(this.gridCurrentData[currentData][currentId]);
i++; i++;
} }
}
} }
} }