From 79d9a1d9b38e1c67249bf5ac78effac45bc42f52 Mon Sep 17 00:00:00 2001 From: rahul shukla Date: Tue, 26 Nov 2019 16:06:22 +0530 Subject: [PATCH] dtabase prefix added in raw query --- .../Webkul/Admin/src/DataGrids/AddressDataGrid.php | 10 +++++----- .../Webkul/Admin/src/DataGrids/CategoryDataGrid.php | 2 +- .../Webkul/Admin/src/DataGrids/CustomerDataGrid.php | 4 ++-- packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php | 8 ++++---- .../Webkul/Admin/src/DataGrids/OrderRefundDataGrid.php | 4 ++-- .../Admin/src/DataGrids/OrderShipmentsDataGrid.php | 4 ++-- .../Webkul/Admin/src/DataGrids/ProductDataGrid.php | 4 ++-- .../Admin/src/Http/Controllers/DashboardController.php | 2 +- .../Shop/src/DataGrids/DownloadableProductDataGrid.php | 4 ++-- 9 files changed, 21 insertions(+), 21 deletions(-) diff --git a/packages/Webkul/Admin/src/DataGrids/AddressDataGrid.php b/packages/Webkul/Admin/src/DataGrids/AddressDataGrid.php index 4c2de244c..0793b9fa3 100644 --- a/packages/Webkul/Admin/src/DataGrids/AddressDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/AddressDataGrid.php @@ -28,19 +28,19 @@ class AddressDataGrid extends DataGrid * @var object */ protected $customer; - + /** * Create a new controller instance. * * @param Webkul\Customer\Repositories\CustomerRepository $customer * @return void */ - public function __construct( + public function __construct( Customer $customer ) { parent::__construct(); - + $this->customer = $customer; } @@ -52,7 +52,7 @@ class AddressDataGrid extends DataGrid $queryBuilder = DB::table('customer_addresses as ca') ->leftJoin('countries', 'ca.country', '=', 'countries.code') ->leftJoin('customers as c', 'ca.customer_id', '=', 'c.id') - ->addSelect('ca.id as address_id', 'ca.address1', 'ca.country', DB::raw('countries.name as country_name'), 'ca.state', 'ca.city', 'ca.postcode', 'ca.phone', 'ca.default_address') + ->addSelect('ca.id as address_id', 'ca.address1', 'ca.country', DB::raw(DB::getTablePrefix().('countries.name as country_name')), 'ca.state', 'ca.city', 'ca.postcode', 'ca.phone', 'ca.default_address') ->where('c.id', $customer->id); $queryBuilder = $queryBuilder->leftJoin('country_states', function($qb) { @@ -62,7 +62,7 @@ class AddressDataGrid extends DataGrid $queryBuilder ->groupBy('ca.id') - ->addSelect(DB::raw('country_states.default_name as state_name')); + ->addSelect(DB::raw(DB::getTablePrefix().('country_states.default_name as state_name'))); $this->addFilter('address_id', 'ca.id'); $this->addFilter('address1', 'ca.address1'); diff --git a/packages/Webkul/Admin/src/DataGrids/CategoryDataGrid.php b/packages/Webkul/Admin/src/DataGrids/CategoryDataGrid.php index 7073e047c..44b174a7b 100755 --- a/packages/Webkul/Admin/src/DataGrids/CategoryDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/CategoryDataGrid.php @@ -21,7 +21,7 @@ class CategoryDataGrid extends DataGrid { $queryBuilder = DB::table('categories as cat') ->select('cat.id as category_id', 'ct.name', 'cat.position', 'cat.status', 'ct.locale', - DB::raw('COUNT(DISTINCT pc.product_id) as count')) + DB::raw('COUNT(DISTINCT ' . DB::getTablePrefix() . 'pc.product_id) as count')) ->leftJoin('category_translations as ct', function($leftJoin) { $leftJoin->on('cat.id', '=', 'ct.category_id') ->where('ct.locale', app()->getLocale()); diff --git a/packages/Webkul/Admin/src/DataGrids/CustomerDataGrid.php b/packages/Webkul/Admin/src/DataGrids/CustomerDataGrid.php index 6952abca6..7345ea683 100755 --- a/packages/Webkul/Admin/src/DataGrids/CustomerDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/CustomerDataGrid.php @@ -25,10 +25,10 @@ class CustomerDataGrid extends DataGrid $queryBuilder = DB::table('customers') ->leftJoin('customer_groups', 'customers.customer_group_id', '=', 'customer_groups.id') ->addSelect('customers.id as customer_id', 'customers.email', 'customer_groups.name', 'customers.phone', 'customers.gender', 'status') - ->addSelect(DB::raw('CONCAT(customers.first_name, " ", customers.last_name) as full_name')); + ->addSelect(DB::raw('CONCAT(' . DB::getTablePrefix() . 'customers.first_name, " ", ' . DB::getTablePrefix() . 'customers.last_name) as full_name')); $this->addFilter('customer_id', 'customers.id'); - $this->addFilter('full_name', DB::raw('CONCAT(customers.first_name, " ", customers.last_name)')); + $this->addFilter('full_name', DB::raw('CONCAT(' . DB::getTablePrefix() . 'customers.first_name, " ", ' . DB::getTablePrefix() . 'customers.last_name)')); $this->addFilter('phone', 'customers.phone'); $this->addFilter('gender', 'customers.gender'); diff --git a/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php b/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php index aa2d91b68..3e8255453 100755 --- a/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php @@ -29,11 +29,11 @@ class OrderDataGrid extends DataGrid ->where('order_address_billing.address_type', 'billing'); }) ->addSelect('orders.id','orders.increment_id', 'orders.base_sub_total', 'orders.base_grand_total', 'orders.created_at', 'channel_name', 'status') - ->addSelect(DB::raw('CONCAT(order_address_billing.first_name, " ", order_address_billing.last_name) as billed_to')) - ->addSelect(DB::raw('CONCAT(order_address_shipping.first_name, " ", order_address_shipping.last_name) as shipped_to')); + ->addSelect(DB::raw('CONCAT(' . DB::getTablePrefix() . 'order_address_billing.first_name, " ", ' . DB::getTablePrefix() . 'order_address_billing.last_name) as billed_to')) + ->addSelect(DB::raw('CONCAT(' . DB::getTablePrefix() . 'order_address_shipping.first_name, " ", ' . DB::getTablePrefix() . 'order_address_shipping.last_name) as shipped_to')); - $this->addFilter('billed_to', DB::raw('CONCAT(order_address_billing.first_name, " ", order_address_billing.last_name)')); - $this->addFilter('shipped_to', DB::raw('CONCAT(order_address_shipping.first_name, " ", order_address_shipping.last_name)')); + $this->addFilter('billed_to', DB::raw('CONCAT(' . DB::getTablePrefix() . 'order_address_billing.first_name, " ", ' . DB::getTablePrefix() . 'order_address_billing.last_name)')); + $this->addFilter('shipped_to', DB::raw('CONCAT(' . DB::getTablePrefix() . 'order_address_shipping.first_name, " ", ' . DB::getTablePrefix() . 'order_address_shipping.last_name)')); $this->addFilter('increment_id', 'orders.increment_id'); $this->addFilter('created_at', 'orders.created_at'); diff --git a/packages/Webkul/Admin/src/DataGrids/OrderRefundDataGrid.php b/packages/Webkul/Admin/src/DataGrids/OrderRefundDataGrid.php index 2e4b09a37..787b1512e 100755 --- a/packages/Webkul/Admin/src/DataGrids/OrderRefundDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/OrderRefundDataGrid.php @@ -26,9 +26,9 @@ class OrderRefundDataGrid extends DataGrid $leftJoin->on('order_address_billing.order_id', '=', 'orders.id') ->where('order_address_billing.address_type', 'billing'); }) - ->addSelect(DB::raw('CONCAT(order_address_billing.first_name, " ", order_address_billing.last_name) as billed_to')); + ->addSelect(DB::raw('CONCAT(' . DB::getTablePrefix() . 'order_address_billing.first_name, " ", ' . DB::getTablePrefix() . 'order_address_billing.last_name) as billed_to')); - $this->addFilter('billed_to', DB::raw('CONCAT(order_address_billing.first_name, " ", order_address_billing.last_name)')); + $this->addFilter('billed_to', DB::raw('CONCAT(' . DB::getTablePrefix() . 'order_address_billing.first_name, " ", ' . DB::getTablePrefix() . 'order_address_billing.last_name)')); $this->addFilter('id', 'refunds.id'); $this->addFilter('increment_id', 'orders.increment_id'); $this->addFilter('state', 'refunds.state'); diff --git a/packages/Webkul/Admin/src/DataGrids/OrderShipmentsDataGrid.php b/packages/Webkul/Admin/src/DataGrids/OrderShipmentsDataGrid.php index 9c94dbf69..ef5f6c647 100755 --- a/packages/Webkul/Admin/src/DataGrids/OrderShipmentsDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/OrderShipmentsDataGrid.php @@ -27,7 +27,7 @@ class OrderShipmentsDataGrid extends DataGrid ->leftJoin('orders as ors', 'shipments.order_id', '=', 'ors.id') ->leftJoin('inventory_sources as is', 'shipments.inventory_source_id', '=', 'is.id') ->select('shipments.id as shipment_id', 'ors.increment_id as shipment_order_id', 'shipments.total_qty as shipment_total_qty', 'is.name as inventory_source_name', 'ors.created_at as order_date', 'shipments.created_at as shipment_created_at') - ->addSelect(DB::raw('CONCAT(order_address_shipping.first_name, " ", order_address_shipping.last_name) as shipped_to')); + ->addSelect(DB::raw('CONCAT(' . DB::getTablePrefix() . 'order_address_shipping.first_name, " ", ' . DB::getTablePrefix() . 'order_address_shipping.last_name) as shipped_to')); $this->addFilter('shipment_id', 'shipments.id'); $this->addFilter('shipment_order_id', 'ors.increment_id'); @@ -35,7 +35,7 @@ class OrderShipmentsDataGrid extends DataGrid $this->addFilter('inventory_source_name', 'is.name'); $this->addFilter('order_date', 'ors.created_at'); $this->addFilter('shipment_created_at', 'shipments.created_at'); - $this->addFilter('shipped_to', DB::raw('CONCAT(order_address_shipping.first_name, " ", order_address_shipping.last_name)')); + $this->addFilter('shipped_to', DB::raw('CONCAT(' . DB::getTablePrefix() . 'order_address_shipping.first_name, " ", ' . DB::getTablePrefix() . 'order_address_shipping.last_name)')); $this->setQueryBuilder($queryBuilder); } diff --git a/packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php b/packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php index bac760717..af1f95a7d 100644 --- a/packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php @@ -25,7 +25,7 @@ class ProductDataGrid extends DataGrid ->leftJoin('products', 'product_flat.product_id', '=', 'products.id') ->leftJoin('attribute_families', 'products.attribute_family_id', '=', 'attribute_families.id') ->leftJoin('product_inventories', 'product_flat.product_id', '=', 'product_inventories.product_id') - ->select('product_flat.product_id as product_id', 'product_flat.sku as product_sku', 'product_flat.name as product_name', 'products.type as product_type', 'product_flat.status', 'product_flat.price', 'attribute_families.name as attribute_family', DB::raw('SUM(product_inventories.qty) as quantity')) + ->select('product_flat.product_id as product_id', 'product_flat.sku as product_sku', 'product_flat.name as product_name', 'products.type as product_type', 'product_flat.status', 'product_flat.price', 'attribute_families.name as attribute_family', DB::raw('SUM(' . DB::getTablePrefix() . 'product_inventories.qty) as quantity')) ->where('channel', core()->getCurrentChannelCode()) ->where('locale', app()->getLocale()) ->groupBy('product_flat.product_id'); @@ -152,7 +152,7 @@ class ProductDataGrid extends DataGrid public function prepareMassActions() { $this->addMassAction([ 'type' => 'delete', - 'label' => 'Delete', + 'label' => 'Delete', 'action' => route('admin.catalog.products.massdelete'), 'method' => 'DELETE' ]); diff --git a/packages/Webkul/Admin/src/Http/Controllers/DashboardController.php b/packages/Webkul/Admin/src/Http/Controllers/DashboardController.php index b9d3d47ba..08a81d355 100755 --- a/packages/Webkul/Admin/src/Http/Controllers/DashboardController.php +++ b/packages/Webkul/Admin/src/Http/Controllers/DashboardController.php @@ -186,7 +186,7 @@ class DashboardController extends Controller ->where('order_items.created_at', '>=', $this->startDate) ->where('order_items.created_at', '<=', $this->endDate) ->addSelect(DB::raw('SUM(qty_invoiced - qty_refunded) as total_qty_invoiced')) - ->addSelect(DB::raw('COUNT(products.id) as total_products')) + ->addSelect(DB::raw('COUNT(' . DB::getTablePrefix() . 'products.id) as total_products')) ->addSelect('order_items.id', 'categories.id as category_id', 'category_translations.name') ->groupBy('categories.id') ->havingRaw('SUM(qty_invoiced - qty_refunded) > 0') diff --git a/packages/Webkul/Shop/src/DataGrids/DownloadableProductDataGrid.php b/packages/Webkul/Shop/src/DataGrids/DownloadableProductDataGrid.php index 74906ae24..32398ca58 100644 --- a/packages/Webkul/Shop/src/DataGrids/DownloadableProductDataGrid.php +++ b/packages/Webkul/Shop/src/DataGrids/DownloadableProductDataGrid.php @@ -22,7 +22,7 @@ class DownloadableProductDataGrid extends DataGrid $queryBuilder = DB::table('downloadable_link_purchased') ->leftJoin('orders', 'downloadable_link_purchased.order_id', '=', 'orders.id') ->addSelect('downloadable_link_purchased.*', 'orders.increment_id') - ->addSelect(DB::raw('(downloadable_link_purchased.download_bought - downloadable_link_purchased.download_used) as remaining_downloads')) + ->addSelect(DB::raw('(' . DB::getTablePrefix() . 'downloadable_link_purchased.download_bought - ' . DB::getTablePrefix() . 'downloadable_link_purchased.download_used) as remaining_downloads')) ->where('downloadable_link_purchased.customer_id', auth()->guard('customer')->user()->id); $this->addFilter('status', 'downloadable_link_purchased.status'); @@ -97,7 +97,7 @@ class DownloadableProductDataGrid extends DataGrid 'wrapper' => function ($value) { if (! $value->download_bought) return trans('shop::app.customer.account.downloadable_products.unlimited'); - + return $value->remaining_downloads; }, ]);