Skip to content

Commit

Permalink
refactor: some keys fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
devansh-webkul committed Aug 24, 2023
1 parent a8300e6 commit fc40c45
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 38 deletions.
2 changes: 1 addition & 1 deletion packages/Webkul/Admin/src/DataGrids/AddressDataGrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public function prepareMassActions()
{
$this->addMassAction([
'title' => trans('admin::app.customers.addresses.delete'),
'action' => route('admin.customer.addresses.mass_delete', request('id')),
'url' => route('admin.customer.addresses.mass_delete', request('id')),
'method' => 'POST',
]);
}
Expand Down
24 changes: 12 additions & 12 deletions packages/Webkul/Admin/src/DataGrids/CustomerDataGrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,25 @@ public function prepareQueryBuilder()
$join->on('customers.id', '=', 'addresses.customer_id')
->where('addresses.address_type', '=', 'customer');
})
->addSelect('customers.id as customer_id')
->addSelect('customers.id as customer_id')
->addSelect(DB::raw('COUNT(DISTINCT addresses.id) as address_count'))
->groupBy('customers.id')
->groupBy('customers.id')

->leftJoin('orders', function ($join) {
$join->on('customers.id', '=', 'orders.customer_id');
})
->addSelect('customers.id as customer_id')
->addSelect('customers.id as customer_id')
->addSelect(DB::raw('COUNT(DISTINCT orders.id) as order_count'))

// ->whereNotIn("orders.status", ['closed', 'canceled'])
->addSelect(
DB::raw("(
DB::raw('(
SUM(DISTINCT base_grand_total) -
SUM(IFNULL((SELECT SUM(base_grand_total) FROM refunds WHERE refunds.order_id = orders.id),0))
) as total_base_grand_total"),
)
->groupBy('customers.id')
) as total_base_grand_total'),
)
->groupBy('customers.id')

->leftJoin('customer_groups', 'customers.customer_group_id', '=', 'customer_groups.id')
->addSelect(
'customers.id as customer_id',
Expand Down Expand Up @@ -139,7 +139,7 @@ public function prepareColumns()
'filterable' => true,
'sortable' => true,
]);

$this->addColumn([
'index' => 'is_suspended',
'label' => trans('admin::app.customers.index.datagrid.suspended'),
Expand Down Expand Up @@ -224,13 +224,13 @@ public function prepareMassActions()
$this->addMassAction([
'title' => trans('admin::app.customers.index.datagrid.delete'),
'method' => 'POST',
'action' => route('admin.customer.mass_delete'),
'url' => route('admin.customer.mass_delete'),
]);

$this->addMassAction([
'title' => trans('admin::app.customers.index.datagrid.update-status'),
'method' => 'POST',
'action' => route('admin.customer.mass_update'),
'url' => route('admin.customer.mass_update'),
'options' => [
trans('admin::app.datagrid.active') => 1,
trans('admin::app.datagrid.inactive') => 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ public function prepareColumns()
'sortable' => true,
]);


$this->addColumn([
'index' => 'rating',
'label' => trans('admin::app.customers.reviews.index.datagrid.rating'),
Expand Down Expand Up @@ -162,14 +161,14 @@ public function prepareMassActions()
{
$this->addMassAction([
'title' => trans('admin::app.customers.reviews.index.datagrid.delete'),
'action' => route('admin.customer.review.mass_delete'),
'url' => route('admin.customer.review.mass_delete'),
'method' => 'POST',
]);

$this->addMassAction([
'title' => trans('admin::app.customers.reviews.index.datagrid.update-status'),
'method' => 'POST',
'action' => route('admin.customer.review.mass_update'),
'url' => route('admin.customer.review.mass_update'),
'options' => [
trans('admin::app.customers.reviews.index.datagrid.pending') => 0,
trans('admin::app.customers.reviews.index.datagrid.approved') => 1,
Expand Down
26 changes: 4 additions & 22 deletions packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
use Webkul\Core\Models\Channel;
use Webkul\Core\Models\Locale;
use Webkul\DataGrid\DataGrid;
use Webkul\Product\Repositories\ProductRepository;
use Webkul\Inventory\Repositories\InventorySourceRepository;
use Webkul\Product\Repositories\ProductRepository;

class ProductDataGrid extends DataGrid
{

/**
* Constructor for the class
*
Expand Down Expand Up @@ -240,35 +239,18 @@ public function prepareMassActions()
{
$this->addMassAction([
'title' => trans('admin::app.datagrid.delete'),
'action' => route('admin.catalog.products.mass_delete'),
'url' => route('admin.catalog.products.mass_delete'),
'method' => 'POST',
]);

$this->addMassAction([
'title' => trans('admin::app.datagrid.update-status'),
'action' => route('admin.catalog.products.mass_update'),
'url' => route('admin.catalog.products.mass_update'),
'method' => 'POST',
'options' => [
trans('admin::app.datagrid.active') => 1,
trans('admin::app.datagrid.inactive') => 0,
],
]);
}

/**
* Render quantity view.
*
* @param object $row
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
*/
private function renderQuantityView($row)
{
$product = $this->productRepository->find($row->product_id);

$inventorySources = $this->inventorySourceRepository->findWhere(['status' => 1]);

$totalQuantity = $row->quantity;

return view('admin::catalog.products.datagrid.quantity', compact('product', 'inventorySources', 'totalQuantity'))->render();
}
}
}

0 comments on commit fc40c45

Please sign in to comment.