Changes in datagrids

This commit is contained in:
Prashant Singh 2019-01-16 19:19:37 +05:30
parent e38763c126
commit 6c9b381d4c
23 changed files with 192 additions and 192 deletions

View File

@ -29,7 +29,6 @@ class AttributeDataGrid extends DataGrid
{
$this->addColumn([
'index' => 'id',
'identifier' => 'attribute_id',
'label' => trans('admin::app.datagrid.id'),
'type' => 'number',
'searchable' => false,
@ -39,7 +38,6 @@ class AttributeDataGrid extends DataGrid
$this->addColumn([
'index' => 'code',
'identifier' => 'attribute_code',
'label' => trans('admin::app.datagrid.code'),
'type' => 'string',
'searchable' => true,
@ -49,7 +47,6 @@ class AttributeDataGrid extends DataGrid
$this->addColumn([
'index' => 'admin_name',
'identifier' => 'attribute_name',
'label' => trans('admin::app.datagrid.admin-name'),
'type' => 'string',
'searchable' => true,
@ -59,7 +56,6 @@ class AttributeDataGrid extends DataGrid
$this->addColumn([
'index' => 'type',
'identifier' => 'attribute_type',
'label' => trans('admin::app.datagrid.type'),
'type' => 'string',
'sortable' => true,
@ -69,7 +65,6 @@ class AttributeDataGrid extends DataGrid
$this->addColumn([
'index' => 'is_required',
'identifier' => 'attribute_is_required',
'label' => trans('admin::app.datagrid.required'),
'type' => 'boolean',
'sortable' => true,
@ -85,7 +80,6 @@ class AttributeDataGrid extends DataGrid
$this->addColumn([
'index' => 'is_unique',
'identifier' => 'attribute_is_unique',
'label' => trans('admin::app.datagrid.unique'),
'type' => 'boolean',
'sortable' => true,
@ -101,7 +95,6 @@ class AttributeDataGrid extends DataGrid
$this->addColumn([
'index' => 'value_per_locale',
'identifier' => 'attribute_value_per_locale',
'label' => trans('admin::app.datagrid.per-locale'),
'type' => 'boolean',
'sortable' => true,
@ -117,7 +110,6 @@ class AttributeDataGrid extends DataGrid
$this->addColumn([
'index' => 'value_per_channel',
'identifier' => 'attribute_value_per_channel',
'label' => trans('admin::app.datagrid.per-channel'),
'type' => 'boolean',
'sortable' => true,

View File

@ -28,7 +28,6 @@ class AttributeFamilyDataGrid extends DataGrid
{
$this->addColumn([
'index' => 'id',
'identifier' => 'id',
'label' => trans('admin::app.datagrid.id'),
'type' => 'number',
'searchable' => false,
@ -38,7 +37,6 @@ class AttributeFamilyDataGrid extends DataGrid
$this->addColumn([
'index' => 'code',
'identifier' => 'code',
'label' => trans('admin::app.datagrid.code'),
'type' => 'string',
'searchable' => true,
@ -48,7 +46,6 @@ class AttributeFamilyDataGrid extends DataGrid
$this->addColumn([
'index' => 'name',
'identifier' => 'name',
'label' => trans('admin::app.datagrid.name'),
'type' => 'string',
'searchable' => true,
@ -72,21 +69,21 @@ class AttributeFamilyDataGrid extends DataGrid
]);
}
public function prepareMassActions() {
// $this->prepareMassAction([
// 'type' => 'delete',
// 'action' => route('admin.catalog.familites.massdelete'),
// 'method' => 'DELETE'
// ]);
// 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,
// ]
// ]);
}
// // $this->prepareMassAction([
// // 'type' => 'update',
// // 'action' => route('admin.catalog.familites.massupdate'),
// // 'method' => 'PUT',
// // 'options' => [
// // 0 => true,
// // 1 => false,
// // ]
// // ]);
// }
}

View File

@ -17,7 +17,13 @@ class CategoryDataGrid extends DataGrid
public function prepareQueryBuilder()
{
$queryBuilder = DB::table('categories as cat')->select('cat.id', 'ct.name', 'cat.position', 'cat.status', 'ct.locale')->leftJoin('category_translations as ct', 'cat.id', '=', 'ct.category_id');
$queryBuilder = DB::table('categories as cat')->select('cat.id as category_id', 'ct.name as category_name', 'cat.position as category_position', 'cat.status as category_status', 'ct.locale as category_locale')->leftJoin('category_translations as ct', 'cat.id', '=', 'ct.category_id');
$this->addFilters('category_id', 'custs.id');
$this->addFilters('category_name', 'ct.name');
$this->addFilters('category_position', 'cat.position');
$this->addFilters('category_status', 'cat.status');
$this->addFilters('category_locale', 'ct.locale');
$this->setQueryBuilder($queryBuilder);
}
@ -25,8 +31,7 @@ class CategoryDataGrid extends DataGrid
public function addColumns()
{
$this->addColumn([
'index' => 'cat.id',
'identifier' => 'category_id',
'index' => 'category_id',
'label' => trans('admin::app.datagrid.id'),
'type' => 'number',
'searchable' => false,
@ -35,8 +40,7 @@ class CategoryDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'ct.name',
'identifier' => 'category_name',
'index' => 'category_name',
'label' => trans('admin::app.datagrid.name'),
'type' => 'string',
'searchable' => true,
@ -45,8 +49,7 @@ class CategoryDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'cat.position',
'identifier' => 'category_position',
'index' => 'category_position',
'label' => trans('admin::app.datagrid.position'),
'type' => 'string',
'searchable' => true,
@ -55,8 +58,7 @@ class CategoryDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'cat.status',
'identifier' => 'category_status',
'index' => 'category_status',
'label' => trans('admin::app.datagrid.status'),
'type' => 'boolean',
'sortable' => true,
@ -71,8 +73,7 @@ class CategoryDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'ct.position',
'identifier' => 'category_locale',
'index' => 'category_locale',
'label' => trans('admin::app.datagrid.locale'),
'type' => 'boolean',
'sortable' => true,

View File

@ -26,7 +26,6 @@ class ChannelDataGrid extends DataGrid
{
$this->addColumn([
'index' => 'id',
'identifier' => 'id',
'label' => trans('admin::app.datagrid.id'),
'type' => 'number',
'searchable' => false,
@ -36,7 +35,6 @@ class ChannelDataGrid extends DataGrid
$this->addColumn([
'index' => 'code',
'identifier' => 'code',
'label' => trans('admin::app.datagrid.code'),
'type' => 'string',
'searchable' => true,
@ -46,7 +44,6 @@ class ChannelDataGrid extends DataGrid
$this->addColumn([
'index' => 'name',
'identifier' => 'name',
'label' => trans('admin::app.datagrid.name'),
'type' => 'string',
'searchable' => true,
@ -56,7 +53,6 @@ class ChannelDataGrid extends DataGrid
$this->addColumn([
'index' => 'hostname',
'identifier' => 'hostname',
'label' => trans('admin::app.datagrid.hostname'),
'type' => 'string',
'sortable' => true,

View File

@ -26,7 +26,6 @@ class CurrencyDataGrid extends DataGrid
{
$this->addColumn([
'index' => 'id',
'identifier' => 'id',
'label' => trans('admin::app.datagrid.id'),
'type' => 'number',
'searchable' => false,
@ -36,7 +35,6 @@ class CurrencyDataGrid extends DataGrid
$this->addColumn([
'index' => 'name',
'identifier' => 'name',
'label' => trans('admin::app.datagrid.name'),
'type' => 'string',
'searchable' => true,
@ -46,7 +44,6 @@ class CurrencyDataGrid extends DataGrid
$this->addColumn([
'index' => 'code',
'identifier' => 'code',
'label' => trans('admin::app.datagrid.code'),
'type' => 'string',
'searchable' => true,

View File

@ -15,11 +15,16 @@ class CustomerDataGrid extends DataGrid
{
protected $itemsPerPage = 5;
protected $index = 'id'; //the column that needs to be treated as index column
protected $index = 'customer_id'; //the column that needs to be treated as index column
public function prepareQueryBuilder()
{
$queryBuilder = DB::table('customers as custs')->addSelect('custs.id', 'custs.email', 'cg.name')->addSelect(DB::raw('CONCAT(custs.first_name, " ", custs.last_name) as full_name'))->leftJoin('customer_groups as cg', 'custs.customer_group_id', '=', 'cg.id');
$queryBuilder = DB::table('customers as custs')->addSelect('custs.id as customer_id', 'custs.email as customer_email', 'cg.name as cust_grp_name')->addSelect(DB::raw('CONCAT(custs.first_name, " ", custs.last_name) as full_name'))->leftJoin('customer_groups as cg', 'custs.customer_group_id', '=', 'cg.id');
$this->addFilters('customer_id', 'custs.id');
$this->addFilters('customer_email', 'custs.email');
$this->addFilters('cust_grp_name', 'cg.name');
$this->addFilters('full_name', DB::raw('CONCAT(custs.first_name, " ", custs.last_name)'));
$this->setQueryBuilder($queryBuilder);
}
@ -27,8 +32,7 @@ class CustomerDataGrid extends DataGrid
public function addColumns()
{
$this->addColumn([
'index' => 'custs.id',
'identifier' => 'customer_id',
'index' => 'customer_id',
'label' => trans('admin::app.datagrid.id'),
'type' => 'number',
'searchable' => true,
@ -38,9 +42,7 @@ class CustomerDataGrid extends DataGrid
$this->addColumn([
'index' => 'full_name',
'identifier' => 'customer_full_name',
'label' => trans('admin::app.datagrid.name'),
'override' => 'having',
'type' => 'string',
'searchable' => true,
'sortable' => true,
@ -48,8 +50,7 @@ class CustomerDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'custs.email',
'identifier' => 'customer_email',
'index' => 'customer_email',
'label' => trans('admin::app.datagrid.email'),
'type' => 'string',
'searchable' => true,
@ -58,8 +59,7 @@ class CustomerDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'cg.name',
'identifier' => 'customer_group_name',
'index' => 'cust_grp_name',
'label' => trans('admin::app.datagrid.group'),
'type' => 'string',
'searchable' => false,

View File

@ -26,7 +26,6 @@ class CustomerGroupDataGrid extends DataGrid
{
$this->addColumn([
'index' => 'id',
'identifier' => 'id',
'label' => 'ID',
'type' => 'number',
'searchable' => false,
@ -36,7 +35,6 @@ class CustomerGroupDataGrid extends DataGrid
$this->addColumn([
'index' => 'name',
'identifier' => 'name',
'label' => 'Name',
'type' => 'string',
'searchable' => true,

View File

@ -17,7 +17,13 @@ class CustomerReviewDataGrid extends DataGrid
public function prepareQueryBuilder()
{
$queryBuilder = DB::table('product_reviews as pr')->addSelect('pr.id', 'pr.title', 'pr.comment', 'pg.name', 'pr.status')->leftjoin('products_grid as pg', 'pr.product_id', '=', 'pg.id');
$queryBuilder = DB::table('product_reviews as pr')->addSelect('pr.id as product_review_id', 'pr.title as product_review_title', 'pr.comment as product_review_comment', 'pg.name as product_name', 'pr.status as product_review_status')->leftjoin('products_grid as pg', 'pr.product_id', '=', 'pg.id');
$this->addFilters('product_review_id', 'pr.id');
$this->addFilters('product_review_title', 'pr.title');
$this->addFilters('product_review_comment', 'pr.comment');
$this->addFilters('product_name', 'pg.name');
$this->addFilters('product_review_status', 'pr.status');
$this->setQueryBuilder($queryBuilder);
}
@ -25,8 +31,7 @@ class CustomerReviewDataGrid extends DataGrid
public function addColumns()
{
$this->addColumn([
'index' => 'pr.id',
'identifier' => 'product_review_id',
'index' => 'product_review_id',
'label' => trans('admin::app.datagrid.id'),
'type' => 'number',
'searchable' => false,
@ -35,8 +40,7 @@ class CustomerReviewDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'pr.title',
'identifier' => 'product_review_title',
'index' => 'product_review_title',
'label' => trans('admin::app.datagrid.title'),
'type' => 'string',
'searchable' => true,
@ -45,8 +49,7 @@ class CustomerReviewDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'pr.comment',
'identifier' => 'product_review_comment',
'index' => 'product_review_comment',
'label' => trans('admin::app.datagrid.comment'),
'type' => 'string',
'searchable' => true,
@ -55,8 +58,7 @@ class CustomerReviewDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'pg.name',
'identifier' => 'product_name',
'index' => 'product_name',
'label' => trans('admin::app.datagrid.product-name'),
'type' => 'string',
'searchable' => true,
@ -65,8 +67,7 @@ class CustomerReviewDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'pr.status',
'identifier' => 'product_review_status',
'index' => 'product_review_status',
'label' => trans('admin::app.datagrid.status'),
'type' => 'boolean',
'searchable' => true,

View File

@ -13,11 +13,15 @@ use DB;
*/
class ExchangeRatesDataGrid extends DataGrid
{
protected $index = 'id';
protected $index = 'currency_exch_id';
public function prepareQueryBuilder()
{
$queryBuilder = DB::table('currency_exchange_rates as cer')->addSelect('cer.id', 'curr.name', 'cer.rate')->leftJoin('currencies as curr', 'cer.target_currency', '=', 'curr.id');
$queryBuilder = DB::table('currency_exchange_rates as cer')->addSelect('cer.id as currency_exch_id', 'curr.name as currency_exch_name', 'cer.rate as currency_exch_rate')->leftJoin('currencies as curr', 'cer.target_currency', '=', 'curr.id');
$this->addFilters('currency_exch_id', 'cer.id');
$this->addFilters('currency_exch_name', 'curr.name');
$this->addFilters('currency_exch_rate', 'cer.rate');
$this->setQueryBuilder($queryBuilder);
}
@ -25,8 +29,7 @@ class ExchangeRatesDataGrid extends DataGrid
public function addColumns()
{
$this->addColumn([
'index' => 'cer.id',
'identifier' => 'currency_exch_id',
'index' => 'currency_exch_id',
'label' => trans('admin::app.datagrid.id'),
'type' => 'number',
'searchable' => false,
@ -35,8 +38,7 @@ class ExchangeRatesDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'curr.name',
'identifier' => 'currency_exch_name',
'index' => 'currency_exch_name',
'label' => trans('admin::app.datagrid.currency-name'),
'type' => 'string',
'searchable' => true,
@ -45,8 +47,7 @@ class ExchangeRatesDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'cer.rate',
'identifier' => 'currency_exch_rate',
'index' => 'currency_exch_rate',
'label' => trans('admin::app.datagrid.exch-rate'),
'type' => 'string',
'searchable' => true,

View File

@ -26,7 +26,6 @@ class InventorySourcesDataGrid extends DataGrid
{
$this->addColumn([
'index' => 'id',
'identifier' => 'id',
'label' => trans('admin::app.datagrid.id'),
'type' => 'number',
'searchable' => false,
@ -36,7 +35,6 @@ class InventorySourcesDataGrid extends DataGrid
$this->addColumn([
'index' => 'code',
'identifier' => 'code',
'label' => trans('admin::app.datagrid.code'),
'type' => 'string',
'searchable' => true,
@ -46,7 +44,6 @@ class InventorySourcesDataGrid extends DataGrid
$this->addColumn([
'index' => 'name',
'identifier' => 'name',
'label' => trans('admin::app.datagrid.name'),
'type' => 'string',
'searchable' => true,
@ -56,7 +53,6 @@ class InventorySourcesDataGrid extends DataGrid
$this->addColumn([
'index' => 'priority',
'identifier' => 'priority',
'label' => trans('admin::app.datagrid.priority'),
'type' => 'string',
'searchable' => true,
@ -66,7 +62,6 @@ class InventorySourcesDataGrid extends DataGrid
$this->addColumn([
'index' => 'status',
'identifier' => 'status',
'label' => trans('admin::app.datagrid.status'),
'type' => 'boolean',
'searchable' => true,

View File

@ -26,7 +26,6 @@ class LocalesDataGrid extends DataGrid
{
$this->addColumn([
'index' => 'id',
'identifier' => 'id',
'label' => trans('admin::app.datagrid.id'),
'type' => 'number',
'searchable' => false,
@ -36,7 +35,6 @@ class LocalesDataGrid extends DataGrid
$this->addColumn([
'index' => 'code',
'identifier' => 'code',
'label' => trans('admin::app.datagrid.code'),
'type' => 'string',
'searchable' => true,
@ -46,7 +44,6 @@ class LocalesDataGrid extends DataGrid
$this->addColumn([
'index' => 'name',
'identifier' => 'name',
'label' => trans('admin::app.datagrid.name'),
'type' => 'string',
'searchable' => true,

View File

@ -26,7 +26,6 @@ class NewsLetterDataGrid extends DataGrid
{
$this->addColumn([
'index' => 'id',
'identifier' => 'id',
'label' => trans('admin::app.datagrid.id'),
'type' => 'number',
'searchable' => false,
@ -36,7 +35,6 @@ class NewsLetterDataGrid extends DataGrid
$this->addColumn([
'index' => 'is_subscribed',
'identifier' => 'is_subscribed',
'label' => trans('admin::app.datagrid.subscribed'),
'type' => 'string',
'searchable' => true,
@ -52,7 +50,6 @@ class NewsLetterDataGrid extends DataGrid
$this->addColumn([
'index' => 'email',
'identifier' => 'email',
'label' => trans('admin::app.datagrid.email'),
'type' => 'string',
'searchable' => true,

View File

@ -19,6 +19,8 @@ class OrderDataGrid extends DataGrid
{
$queryBuilder = DB::table('orders')->select('id', 'base_grand_total', 'grand_total', 'created_at', 'channel_name', 'status')->addSelect(DB::raw('CONCAT(customer_first_name, " ", customer_last_name) as full_name'));
$this->addFilters('full_name', DB::raw('CONCAT(customer_first_name, " ", customer_last_name)'));
$this->setQueryBuilder($queryBuilder);
}
@ -26,7 +28,6 @@ class OrderDataGrid extends DataGrid
{
$this->addColumn([
'index' => 'id',
'identifier' => 'id',
'label' => trans('admin::app.datagrid.id'),
'type' => 'number',
'searchable' => false,
@ -36,10 +37,9 @@ class OrderDataGrid extends DataGrid
$this->addColumn([
'index' => 'base_grand_total',
'identifier' => 'base_grand_total',
'label' => trans('admin::app.datagrid.base-total'),
'type' => 'string',
'searchable' => true,
'searchable' => false,
'sortable' => true,
'width' => '100px',
'wrapper' => function ($value) {
@ -49,10 +49,9 @@ class OrderDataGrid extends DataGrid
$this->addColumn([
'index' => 'grand_total',
'identifier' => 'grand_total',
'label' => trans('admin::app.datagrid.grand-total'),
'type' => 'string',
'searchable' => true,
'searchable' => false,
'sortable' => true,
'width' => '100px',
'wrapper' => function ($value) {
@ -62,31 +61,28 @@ class OrderDataGrid extends DataGrid
$this->addColumn([
'index' => 'created_at',
'identifier' => 'created_at',
'label' => trans('admin::app.datagrid.order-date'),
'type' => 'string',
'type' => 'datetime',
'sortable' => true,
'searchable' => true,
'searchable' => false,
'width' => '100px',
]);
$this->addColumn([
'index' => 'channel_name',
'identifier' => 'channel_name',
'label' => trans('admin::app.datagrid.channel-name'),
'type' => 'string',
'sortable' => true,
'searchable' => false,
'searchable' => true,
'width' => '100px'
]);
$this->addColumn([
'index' => 'status',
'identifier' => 'status',
'label' => trans('admin::app.datagrid.status'),
'type' => 'string',
'sortable' => true,
'searchable' => false,
'searchable' => true,
'width' => '100px',
'closure' => true,
'wrapper' => function ($value) {
@ -109,10 +105,9 @@ class OrderDataGrid extends DataGrid
$this->addColumn([
'index' => 'full_name',
'identifier' => 'full_name',
'label' => trans('admin::app.datagrid.billed-to'),
'type' => 'string',
'searchable' => false,
'searchable' => true,
'sortable' => true,
'width' => '100px'
]);

View File

@ -26,7 +26,6 @@ class OrderInvoicesDataGrid extends DataGrid
{
$this->addColumn([
'index' => 'id',
'identifier' => 'id',
'label' => trans('admin::app.datagrid.id'),
'type' => 'number',
'searchable' => false,
@ -36,7 +35,6 @@ class OrderInvoicesDataGrid extends DataGrid
$this->addColumn([
'index' => 'order_id',
'identifier' => 'order_id',
'label' => trans('admin::app.datagrid.order-id'),
'type' => 'number',
'searchable' => false,
@ -46,7 +44,6 @@ class OrderInvoicesDataGrid extends DataGrid
$this->addColumn([
'index' => 'grand_total',
'identifier' => 'grand_total',
'label' => trans('admin::app.datagrid.grand-total'),
'type' => 'string',
'searchable' => true,
@ -56,7 +53,6 @@ class OrderInvoicesDataGrid extends DataGrid
$this->addColumn([
'index' => 'created_at',
'identifier' => 'created_at',
'label' => trans('admin::app.datagrid.invoice-date'),
'type' => 'datetime',
'searchable' => true,

View File

@ -17,7 +17,15 @@ class OrderShipmentsDataGrid extends DataGrid
public function prepareQueryBuilder()
{
$queryBuilder = DB::table('shipments as ship')->select('ship.id', 'ship.order_id', 'ship.total_qty', 'is.name', 'ors.created_at', 'ship.created_at')->addSelect(DB::raw('CONCAT(ors.customer_first_name, " ", ors.customer_last_name) as custname'))->leftJoin('orders as ors', 'ship.order_id', '=', 'ors.id')->leftJoin('inventory_sources as is', 'ship.inventory_source_id', '=', 'is.id');
$queryBuilder = DB::table('shipments as ship')->select('ship.id as shipment_id', 'ship.order_id as shipment_order_id', 'ship.total_qty as shipment_total_qty', 'is.name as inventory_source_name', 'ors.created_at as orderdate', 'ship.created_at as shipment_created_at')->addSelect(DB::raw('CONCAT(ors.customer_first_name, " ", ors.customer_last_name) as custname'))->leftJoin('orders as ors', 'ship.order_id', '=', 'ors.id')->leftJoin('inventory_sources as is', 'ship.inventory_source_id', '=', 'is.id');
$this->addFilters('shipment_id', 'ship.id');
$this->addFilters('shipment_order_id', 'ship.order_id');
$this->addFilters('shipment_total_qty', 'ship.total_qty');
$this->addFilters('inventory_source_name', 'is.name');
$this->addFilters('orderdate', 'ors.created_at');
$this->addFilters('shipment_created_at', 'ship.created_at');
$this->addFilters('custname', DB::raw('CONCAT(ors.customer_first_name, " ", ors.customer_last_name)'));
$this->setQueryBuilder($queryBuilder);
}
@ -25,38 +33,34 @@ class OrderShipmentsDataGrid extends DataGrid
public function addColumns()
{
$this->addColumn([
'index' => 'ship.id',
'identifier' => 'shipment_id',
'index' => 'shipment_id',
'label' => trans('admin::app.datagrid.id'),
'type' => 'number',
'searchable' => false,
'searchable' => true,
'sortable' => true,
'width' => '40px'
]);
$this->addColumn([
'index' => 'ship.order_id',
'identifier' => 'shipment_order_id',
'index' => 'shipment_order_id',
'label' => trans('admin::app.datagrid.order-id'),
'type' => 'number',
'searchable' => false,
'searchable' => true,
'sortable' => true,
'width' => '100px'
]);
$this->addColumn([
'index' => 'ship.total_qty',
'identifier' => 'shipment_total_qty',
'index' => 'shipment_total_qty',
'label' => trans('admin::app.datagrid.total-qty'),
'type' => 'number',
'searchable' => true,
'searchable' => false,
'sortable' => true,
'width' => '100px',
]);
$this->addColumn([
'index' => 'is.name',
'identifier' => 'inventory_source_name',
'index' => 'inventory_source_name',
'label' => trans('admin::app.datagrid.inventory-source'),
'type' => 'string',
'searchable' => true,
@ -65,18 +69,16 @@ class OrderShipmentsDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'ors.created_at',
'identifier' => 'orderdate',
'index' => 'orderdate',
'label' => trans('admin::app.datagrid.order-date'),
'type' => 'datetime',
'sortable' => true,
'searchable' => true,
'searchable' => false,
'width' => '100px'
]);
$this->addColumn([
'index' => 'ship.created_at',
'identifier' => 'shipment_created_at',
'index' => 'shipment_created_at',
'label' => trans('admin::app.datagrid.shipment-date'),
'type' => 'datetime',
'sortable' => true,
@ -86,11 +88,10 @@ class OrderShipmentsDataGrid extends DataGrid
$this->addColumn([
'index' => 'custname',
'identifier' => 'custname',
'label' => trans('admin::app.datagrid.shipment-to'),
'type' => 'string',
'sortable' => true,
'searchable' => false,
'searchable' => true,
'width' => '100px'
]);
}

View File

@ -17,7 +17,15 @@ class ProductDataGrid extends DataGrid
public function prepareQueryBuilder()
{
$queryBuilder = DB::table('products_grid as pg')->addSelect('pg.product_id', 'pg.sku', 'pg.name', 'pr.type', 'pg.status', 'pg.price', 'pg.quantity')->leftJoin('products as pr', 'pg.product_id', '=', 'pr.id');
$queryBuilder = DB::table('products_grid as pg')->addSelect('pg.product_id as product_id', 'pg.sku as product_sku', 'pg.name as product_name', 'pr.type as product_type', 'pg.status as product_status', 'pg.price as product_price', 'pg.quantity as product_qty')->leftJoin('products as pr', 'pg.product_id', '=', 'pr.id');
$this->addFilters('product_id', 'pg.product_id');
$this->addFilters('product_sku', 'pg.sku');
$this->addFilters('product_name', 'pg.name');
$this->addFilters('product_type', 'pr.type');
$this->addFilters('product_status', 'pg.status');
$this->addFilters('product_price', 'pg.price');
$this->addFilters('product_qty', 'pg.quantity');
$this->setQueryBuilder($queryBuilder);
}
@ -25,8 +33,7 @@ class ProductDataGrid extends DataGrid
public function addColumns()
{
$this->addColumn([
'index' => 'pg.product_id',
'identifier' => 'product_id',
'index' => 'product_id',
'label' => trans('admin::app.datagrid.id'),
'type' => 'number',
'searchable' => false,
@ -35,8 +42,7 @@ class ProductDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'pg.sku',
'identifier' => 'product_sku',
'index' => 'product_sku',
'label' => trans('admin::app.datagrid.sku'),
'type' => 'string',
'searchable' => true,
@ -45,8 +51,7 @@ class ProductDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'pg.name',
'identifier' => 'product_name',
'index' => 'product_name',
'label' => trans('admin::app.datagrid.name'),
'type' => 'string',
'searchable' => true,
@ -55,8 +60,7 @@ class ProductDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'pr.type',
'identifier' => 'product_type',
'index' => 'product_type',
'label' => trans('admin::app.datagrid.type'),
'type' => 'string',
'sortable' => true,
@ -65,8 +69,7 @@ class ProductDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'pg.status',
'identifier' => 'product_status',
'index' => 'product_status',
'label' => trans('admin::app.datagrid.status'),
'type' => 'boolean',
'sortable' => true,
@ -81,8 +84,7 @@ class ProductDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'pg.price',
'identifier' => 'product_price',
'index' => 'product_price',
'label' => trans('admin::app.datagrid.price'),
'type' => 'number',
'sortable' => true,
@ -94,8 +96,7 @@ class ProductDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'pg.quantity',
'identifier' => 'product_quantity',
'index' => 'product_qty',
'label' => trans('admin::app.datagrid.qty'),
'type' => 'number',
'sortable' => true,

View File

@ -26,7 +26,6 @@ class RolesDataGrid extends DataGrid
{
$this->addColumn([
'index' => 'id',
'identifier' => 'id',
'label' => trans('admin::app.datagrid.id'),
'type' => 'number',
'searchable' => false,
@ -36,7 +35,6 @@ class RolesDataGrid extends DataGrid
$this->addColumn([
'index' => 'name',
'identifier' => 'name',
'label' => trans('admin::app.datagrid.name'),
'type' => 'string',
'searchable' => true,
@ -46,7 +44,6 @@ class RolesDataGrid extends DataGrid
$this->addColumn([
'index' => 'permission_type',
'identifier' => 'permission_type',
'label' => trans('admin::app.datagrid.permission-type'),
'type' => 'string',
'searchable' => true,

View File

@ -17,7 +17,12 @@ class SliderDataGrid extends DataGrid
public function prepareQueryBuilder()
{
$queryBuilder = DB::table('sliders as sl')->addSelect('sl.id', 'sl.title', 'ch.name')->leftJoin('channels as ch', 'sl.channel_id', '=', 'ch.id');
$queryBuilder = DB::table('sliders as sl')->addSelect('sl.id as slider_id', 'sl.title as slider_title', 'ch.name as channel_name')->leftJoin('channels as ch', 'sl.channel_id', '=',
'ch.id');
$this->addFilters('slider_id', 'sl.id');
$this->addFilters('slider_title', 'sl.title');
$this->addFilters('channel_name', 'ch.name');
$this->setQueryBuilder($queryBuilder);
}
@ -25,8 +30,7 @@ class SliderDataGrid extends DataGrid
public function addColumns()
{
$this->addColumn([
'index' => 'sl.id',
'identifier' => 'slider_id',
'index' => 'slider_id',
'label' => trans('admin::app.datagrid.id'),
'type' => 'number',
'searchable' => false,
@ -35,8 +39,7 @@ class SliderDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'sl.title',
'identifier' => 'slider_title',
'index' => 'slider_title',
'label' => trans('admin::app.datagrid.title'),
'type' => 'string',
'searchable' => true,
@ -45,8 +48,7 @@ class SliderDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'ch.name',
'identifier' => 'channel_name',
'index' => 'channel_name',
'label' => trans('admin::app.datagrid.channel-name'),
'type' => 'string',
'searchable' => true,

View File

@ -26,7 +26,6 @@ class TaxCategoryDataGrid extends DataGrid
{
$this->addColumn([
'index' => 'id',
'identifier' => 'id',
'label' => trans('admin::app.datagrid.id'),
'type' => 'number',
'searchable' => false,
@ -36,7 +35,6 @@ class TaxCategoryDataGrid extends DataGrid
$this->addColumn([
'index' => 'name',
'identifier' => 'name',
'label' => trans('admin::app.datagrid.name'),
'type' => 'string',
'searchable' => true,
@ -46,7 +44,6 @@ class TaxCategoryDataGrid extends DataGrid
$this->addColumn([
'index' => 'code',
'identifier' => 'code',
'label' => trans('admin::app.datagrid.code'),
'type' => 'string',
'searchable' => true,

View File

@ -26,7 +26,6 @@ class TaxRateDataGrid extends DataGrid
{
$this->addColumn([
'index' => 'id',
'identifier' => 'id',
'label' => trans('admin::app.datagrid.id'),
'type' => 'number',
'searchable' => false,
@ -36,7 +35,6 @@ class TaxRateDataGrid extends DataGrid
$this->addColumn([
'index' => 'identifier',
'identifier' => 'identifier',
'label' => trans('admin::app.datagrid.identifier'),
'type' => 'string',
'searchable' => true,
@ -46,7 +44,6 @@ class TaxRateDataGrid extends DataGrid
$this->addColumn([
'index' => 'state',
'identifier' => 'state',
'label' => trans('admin::app.datagrid.state'),
'type' => 'string',
'searchable' => true,
@ -56,7 +53,6 @@ class TaxRateDataGrid extends DataGrid
$this->addColumn([
'index' => 'country',
'identifier' => 'country',
'label' => trans('admin::app.datagrid.country'),
'type' => 'string',
'searchable' => true,
@ -66,7 +62,6 @@ class TaxRateDataGrid extends DataGrid
$this->addColumn([
'index' => 'tax_rate',
'identifier' => 'tax_rate',
'label' => trans('admin::app.datagrid.tax-rate'),
'type' => 'string',
'searchable' => true,

View File

@ -13,11 +13,17 @@ use DB;
*/
class UserDataGrid extends DataGrid
{
protected $index = 'id';
protected $index = 'user_id';
public function prepareQueryBuilder()
{
$queryBuilder = DB::table('admins as u')->addSelect('u.id', 'u.name', 'u.status', 'u.email', 'ro.name')->leftJoin('roles as ro', 'u.role_id', '=', 'ro.id');
$queryBuilder = DB::table('admins as u')->addSelect('u.id as user_id', 'u.name as user_name', 'u.status as user_status', 'u.email as user_email', 'ro.name as role_name')->leftJoin('roles as ro', 'u.role_id', '=', 'ro.id');
$this->addFilters('user_id', 'u.id');
$this->addFilters('user_name', 'u.name');
$this->addFilters('user_status', 'u.status');
$this->addFilters('user_email', 'u.email');
$this->addFilters('role_name', 'ro.name');
$this->setQueryBuilder($queryBuilder);
}
@ -25,8 +31,7 @@ class UserDataGrid extends DataGrid
public function addColumns()
{
$this->addColumn([
'index' => 'u.id',
'identifier' => 'user_id',
'index' => 'user_id',
'label' => trans('admin::app.datagrid.id'),
'type' => 'number',
'searchable' => false,
@ -35,8 +40,7 @@ class UserDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'u.name',
'identifier' => 'user_name',
'index' => 'user_name',
'label' => trans('admin::app.datagrid.name'),
'type' => 'string',
'searchable' => true,
@ -45,8 +49,7 @@ class UserDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'u.status',
'identifier' => 'user_status',
'index' => 'user_status',
'label' => trans('admin::app.datagrid.status'),
'type' => 'boolean',
'searchable' => true,
@ -62,8 +65,7 @@ class UserDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'u.email',
'identifier' => 'user_email',
'index' => 'user_email',
'label' => trans('admin::app.datagrid.email'),
'type' => 'string',
'searchable' => true,
@ -72,8 +74,7 @@ class UserDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'ro.name',
'identifier' => 'role_name',
'index' => 'role_name',
'label' => trans('admin::app.datagrid.role'),
'type' => 'string',
'searchable' => true,

View File

@ -13,6 +13,8 @@ use Illuminate\Http\Request;
abstract class DataGrid
{
protected $index = null;
protected $enableFilterMap = false;
protected $filterMap = [];
protected $columns = [];
protected $completeColumnDetails = [];
protected $queryBuilder = [];
@ -46,6 +48,17 @@ abstract class DataGrid
return $parsedUrl;
}
/**
* Add the index as alias of the column and use the column to make things happen
*
* @return void
*/
public function addFilters($alias, $column) {
$this->filterMap[$alias] = $column;
$this->enableFilterMap = true;
}
public function addColumn($column)
{
array_push($this->columns, $column);
@ -111,7 +124,7 @@ abstract class DataGrid
public function findColumnType($columnAlias)
{
foreach($this->completeColumnDetails as $column) {
if($column['identifier'] == $columnAlias) {
if($column['index'] == $columnAlias) {
return [$column['type'], $column['index']];
}
}
@ -146,36 +159,66 @@ abstract class DataGrid
if ($count_keys == 1) {
return $collection->where(function() use($collection, $info) {
foreach ($this->completeColumnDetails as $column) {
if ($column['searchable'] == true)
$collection->orWhere($column['index'], 'like', '%'.$info['all'].'%');
if ($column['searchable'] == true) {
if($this->enableFilterMap && isset($this->filterMap[$column['index']])) {
$collection->orWhere($this->filterMap[$column['index']], 'like', '%'.$info['all'].'%');
} else {
$collection->orWhere($column['index'], 'like', '%'.$info['all'].'%');
}
}
}
});
}
} else {
if (array_keys($info)[0] == "like" || array_keys($info)[0] == "nlike") {
foreach ($info as $condition => $filter_value) {
return $collection->where(
$columnName,
config("datagrid.operators.{$condition}"),
'%'.$filter_value.'%'
);
}
} else {
foreach ($info as $condition => $filter_value) {
if ($columnType == 'datetime') {
return $collection->whereDate(
$columnName,
if ($this->enableFilterMap && isset($this->filterMap[$columnName])) {
return $collection->where(
$this->filterMap[$columnName],
config("datagrid.operators.{$condition}"),
$filter_value
'%'.$filter_value.'%'
);
} else {
return $collection->where(
$columnName,
config("datagrid.operators.{$condition}"),
$filter_value
'%'.$filter_value.'%'
);
}
}
} else {
foreach ($info as $condition => $filter_value) {
if ($columnType == 'datetime') {
if ($this->enableFilterMap && isset($this->filterMap[$columnName])) {
return $collection->whereDate(
$this->filterMap[$columnname],
config("datagrid.operators.{$condition}"),
$filter_value
);
} else {
return $collection->whereDate(
$columnName,
config("datagrid.operators.{$condition}"),
$filter_value
);
}
} else {
if ($this->enableFilterMap && isset($this->filterMap[$column['index']])) {
return $collection->where(
$this->filterMap[$columnName],
config("datagrid.operators.{$condition}"),
$filter_value
);
} else {
return $collection->where(
$columnName,
config("datagrid.operators.{$condition}"),
$filter_value
);
}
}
}
}
}
}

View File

@ -35,7 +35,7 @@
<select class="filter-column-select control" v-model="filterColumn" v-on:click="getColumnOrAlias(filterColumn)">
<option selected disabled>Select Column</option>
@foreach($results['columns'] as $column)
<option value="{{ $column['identifier'] }}">
<option value="{{ $column['index'] }}">
{{ $column['label'] }}
</option>
@endforeach
@ -197,7 +197,7 @@
@endif
@foreach($results['columns'] as $key => $column)
<th class="grid_head" style="width: {{ $column['width'] }}" v-on:click="sortCollection('{{ $column['identifier'] }}')">
<th class="grid_head" style="width: {{ $column['width'] }}" v-on:click="sortCollection('{{ $column['index'] }}')">
{{ $column['label'] }}
</th>
@endforeach
@ -268,7 +268,7 @@
this.columnOrAlias = columnOrAlias;
for(column in this.columns) {
if (this.columns[column].identifier == this.columnOrAlias) {
if (this.columns[column].index == this.columnOrAlias) {
this.type = this.columns[column].type;
if (this.type == 'string') {
@ -315,7 +315,7 @@
label = '';
for(colIndex in this.columns) {
if(this.columns[colIndex].identifier == this.columnOrAlias) {
if(this.columns[colIndex].index == this.columnOrAlias) {
label = this.columns[colIndex].label;
}
}
@ -335,7 +335,7 @@
label = '';
for(colIndex in this.columns) {
if(this.columns[colIndex].identifier == alias) {
if(this.columns[colIndex].index == alias) {
matched = 0;
label = this.columns[colIndex].label;
}
@ -601,7 +601,7 @@
label = '';
for(colIndex in this.columns) {
if(this.columns[colIndex].identifier == obj.cond) {
if(this.columns[colIndex].index == obj.cond) {
obj.label = this.columns[colIndex].label;
}
@ -612,7 +612,7 @@
obj.label = '';
for(colIndex in this.columns) {
if(this.columns[colIndex].identifier == obj.column) {
if(this.columns[colIndex].index == obj.column) {
obj.label = this.columns[colIndex].label;
}
}