diff --git a/packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php b/packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php index bdbeeceb8..a3262a8b6 100644 --- a/packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php @@ -5,8 +5,6 @@ namespace Webkul\Admin\DataGrids; use Illuminate\Support\Facades\DB; use Webkul\Core\Models\Channel; use Webkul\Core\Models\Locale; -use Webkul\Inventory\Repositories\InventorySourceRepository; -use Webkul\Product\Repositories\ProductRepository; use Webkul\Ui\DataGrid\DataGrid; class ProductDataGrid extends DataGrid @@ -56,33 +54,12 @@ class ProductDataGrid extends DataGrid 'locales', ]; - /** - * Product repository instance. - * - * @var \Webkul\Product\Repositories\ProductRepository - */ - protected $productRepository; - - /** - * Inventory source repository instance. - * - * @var \Webkul\Inventory\Repositories\InventorySourceRepository - */ - protected $inventorySourceRepository; - /** * Create datagrid instance. * - * @param \Webkul\Product\Repositories\ProductRepository $productRepository - * @param \Webkul\Inventory\Repositories\InventorySourceRepository $inventorySourceRepository * @return void */ - public function __construct( - ProductRepository $productRepository, - InventorySourceRepository $inventorySourceRepository - ) { - parent::__construct(); - + public function __construct() { /* locale */ $this->locale = core()->getRequestedLocaleCode(); @@ -95,9 +72,8 @@ class ProductDataGrid extends DataGrid $this->channel = $this->channel ? $this->channel->code : 'all'; } - $this->productRepository = $productRepository; - - $this->inventorySourceRepository = $inventorySourceRepository; + /* parent constructor */ + parent::__construct(); } /** @@ -281,6 +257,13 @@ class ProductDataGrid extends DataGrid 'confirm_text' => trans('ui::app.datagrid.massaction.delete', ['resource' => 'product']), 'icon' => 'icon trash-icon', ]); + + $this->addAction([ + 'title' => trans('admin::app.datagrid.copy'), + 'method' => 'GET', + 'route' => 'admin.catalog.products.copy', + 'icon' => 'icon copy-icon', + ]); } /** @@ -290,13 +273,6 @@ class ProductDataGrid extends DataGrid */ public function prepareMassActions() { - $this->addAction([ - 'title' => trans('admin::app.datagrid.copy'), - 'method' => 'GET', - 'route' => 'admin.catalog.products.copy', - 'icon' => 'icon copy-icon', - ]); - $this->addMassAction([ 'type' => 'delete', 'label' => trans('admin::app.datagrid.delete'), @@ -319,14 +295,14 @@ class ProductDataGrid extends DataGrid /** * Render quantity view. * - * @parma object $row + * @param object $row * @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory */ private function renderQuantityView($row) { - $product = $this->productRepository->find($row->product_id); + $product = app(\Webkul\Product\Repositories\ProductRepository::class)->find($row->product_id); - $inventorySources = $this->inventorySourceRepository->findWhere(['status' => 1]); + $inventorySources = app(\Webkul\Inventory\Repositories\InventorySourceRepository::class)->findWhere(['status' => 1]); $totalQuantity = $row->quantity; diff --git a/packages/Webkul/Admin/src/Http/Controllers/ExportController.php b/packages/Webkul/Admin/src/Http/Controllers/ExportController.php index 1463e2b6b..5d7e761ce 100755 --- a/packages/Webkul/Admin/src/Http/Controllers/ExportController.php +++ b/packages/Webkul/Admin/src/Http/Controllers/ExportController.php @@ -2,8 +2,8 @@ namespace Webkul\Admin\Http\Controllers; -use Webkul\Admin\Exports\DataGridExport; use Excel; +use Webkul\Admin\Exports\DataGridExport; class ExportController extends Controller { @@ -18,10 +18,10 @@ class ExportController extends Controller } /** - * function for export datagrid + * Export datagrid. * * @return \Illuminate\Http\Response - */ + */ public function export() { $criteria = request()->all(); @@ -30,10 +30,10 @@ class ExportController extends Controller $gridName = explode('\\', $criteria['gridName']); - $path = '\Webkul\Admin\DataGrids'.'\\'.last($gridName); + $path = '\Webkul\Admin\DataGrids' . '\\' . last($gridName); $gridInstance = new $path; - + $records = $gridInstance->export(); if (! count($records)) { @@ -43,15 +43,15 @@ class ExportController extends Controller } if ($format == 'csv') { - return Excel::download(new DataGridExport($records), last($gridName).'.csv'); + return Excel::download(new DataGridExport($records), last($gridName) . '.csv'); } if ($format == 'xls') { - return Excel::download(new DataGridExport($records), last($gridName).'.xlsx'); + return Excel::download(new DataGridExport($records), last($gridName) . '.xlsx'); } session()->flash('warning', trans('admin::app.export.illegal-format')); return redirect()->back(); } -} \ No newline at end of file +}