diff --git a/composer.json b/composer.json
index 5280854d0..76fc059b4 100644
--- a/composer.json
+++ b/composer.json
@@ -20,6 +20,7 @@
"konekt/concord": "^1.2",
"laravel/framework": "5.6.*",
"laravel/tinker": "^1.0",
+ "maatwebsite/excel": "3.1.x-dev",
"nwidart/laravel-modules": "^3.2",
"prettus/l5-repository": "^2.6",
"propaganistas/laravel-intl": "^2.0"
diff --git a/config/app.php b/config/app.php
index 4a55945f9..e56125308 100644
--- a/config/app.php
+++ b/config/app.php
@@ -194,6 +194,9 @@ return [
//Laravel Intervention
Intervention\Image\ImageServiceProvider::class,
+ //Laravel Maatwebsite
+ Maatwebsite\Excel\ExcelServiceProvider::class,
+
//Repository
Prettus\Repository\Providers\RepositoryServiceProvider::class,
Konekt\Concord\ConcordServiceProvider::class,
@@ -274,5 +277,6 @@ return [
'Core' => Webkul\Core\Facades\Core::class,
'DbView' => Flynsarmy\DbBladeCompiler\Facades\DbView::class,
'PDF' => Barryvdh\DomPDF\Facade::class,
+ 'Excel' => Maatwebsite\Excel\Facades\Excel::class,
],
];
\ No newline at end of file
diff --git a/config/excel.php b/config/excel.php
new file mode 100644
index 000000000..af3e8bb99
--- /dev/null
+++ b/config/excel.php
@@ -0,0 +1,112 @@
+ [
+
+ /*
+ |--------------------------------------------------------------------------
+ | Chunk size
+ |--------------------------------------------------------------------------
+ |
+ | When using FromQuery, the query is automatically chunked.
+ | Here you can specify how big the chunk should be.
+ |
+ */
+ 'chunk_size' => 1000,
+
+ /*
+ |--------------------------------------------------------------------------
+ | Temporary path
+ |--------------------------------------------------------------------------
+ |
+ | When exporting files, we use a temporary file, before storing
+ | or downloading. Here you can customize that path.
+ |
+ */
+ 'temp_path' => sys_get_temp_dir(),
+
+ /*
+ |--------------------------------------------------------------------------
+ | Pre-calculate formulas during export
+ |--------------------------------------------------------------------------
+ */
+ 'pre_calculate_formulas' => false,
+
+ /*
+ |--------------------------------------------------------------------------
+ | CSV Settings
+ |--------------------------------------------------------------------------
+ |
+ | Configure e.g. delimiter, enclosure and line ending for CSV exports.
+ |
+ */
+ 'csv' => [
+ 'delimiter' => ',',
+ 'enclosure' => '"',
+ 'line_ending' => PHP_EOL,
+ 'use_bom' => false,
+ 'include_separator_line' => false,
+ 'excel_compatibility' => false,
+ ],
+ ],
+
+ 'imports' => [
+
+ 'read_only' => true,
+
+ 'heading_row' => [
+
+ /*
+ |--------------------------------------------------------------------------
+ | Heading Row Formatter
+ |--------------------------------------------------------------------------
+ |
+ | Configure the heading row formatter.
+ | Available options: none|slug|custom
+ |
+ */
+ 'formatter' => 'slug',
+ ],
+ ],
+
+ /*
+ |--------------------------------------------------------------------------
+ | Extension detector
+ |--------------------------------------------------------------------------
+ |
+ | Configure here which writer type should be used when
+ | the package needs to guess the correct type
+ | based on the extension alone.
+ |
+ */
+ 'extension_detector' => [
+ 'xlsx' => Excel::XLSX,
+ 'xlsm' => Excel::XLSX,
+ 'xltx' => Excel::XLSX,
+ 'xltm' => Excel::XLSX,
+ 'xls' => Excel::XLS,
+ 'xlt' => Excel::XLS,
+ 'ods' => Excel::ODS,
+ 'ots' => Excel::ODS,
+ 'slk' => Excel::SLK,
+ 'xml' => Excel::XML,
+ 'gnumeric' => Excel::GNUMERIC,
+ 'htm' => Excel::HTML,
+ 'html' => Excel::HTML,
+ 'csv' => Excel::CSV,
+ 'tsv' => Excel::TSV,
+
+ /*
+ |--------------------------------------------------------------------------
+ | PDF Extension
+ |--------------------------------------------------------------------------
+ |
+ | Configure here which Pdf driver should be used by default.
+ | Available options: Excel::MPDF | Excel::TCPDF | Excel::DOMPDF
+ |
+ */
+ 'pdf' => Excel::DOMPDF,
+ ],
+];
diff --git a/packages/Webkul/Admin/src/Exceptions/Handler.php b/packages/Webkul/Admin/src/Exceptions/Handler.php
index 1444b9217..4a6d2d88f 100644
--- a/packages/Webkul/Admin/src/Exceptions/Handler.php
+++ b/packages/Webkul/Admin/src/Exceptions/Handler.php
@@ -22,6 +22,7 @@ class Handler extends ExceptionHandler
*/
public function render($request, Exception $exception)
{
+
if ($exception instanceof HttpException) {
$statusCode = $exception->getStatusCode();
if (strpos($_SERVER['REQUEST_URI'], 'admin') !== false) {
@@ -53,27 +54,26 @@ class Handler extends ExceptionHandler
return response()->view('shop::errors.500', [], 500);
}
}
- } else if ($exception instanceof ModelNotFoundException) {
+ } else if ($exception instanceof \ModelNotFoundException) {
if (strpos($_SERVER['REQUEST_URI'], 'admin') !== false){
return response()->view('admin::errors.404', [], 404);
}else {
return response()->view('shop::errors.404', [], 404);
}
- } else if ($exception instanceof PDOException) {
+ } else if ($exception instanceof \PDOException) {
if (strpos($_SERVER['REQUEST_URI'], 'admin') !== false){
return response()->view('admin::errors.500', [], 500);
} else {
return response()->view('shop::errors.500', [], 500);
}
}
- // else if ($exception instanceof ErrorException) {
+ // else if ($exception instanceof \ErrorException) {
// if(strpos($_SERVER['REQUEST_URI'], 'admin') !== false){
// return response()->view('admin::errors.500', [], 500);
// }else {
// return response()->view('shop::errors.500', [], 500);
// }
-
// }
return parent::render($request, $exception);
diff --git a/packages/Webkul/Admin/src/Exports/DataGridExport.php b/packages/Webkul/Admin/src/Exports/DataGridExport.php
new file mode 100644
index 000000000..5aa20e4ad
--- /dev/null
+++ b/packages/Webkul/Admin/src/Exports/DataGridExport.php
@@ -0,0 +1,53 @@
+
+ * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
+ */
+
+class DataGridExport implements FromView, ShouldAutoSize
+{
+
+ /**
+ * DataGrid instance
+ *
+ * @var mixed
+ */
+ public $gridData;
+
+ /**
+ * Create a new instance.
+ *
+ * @param mixed DataGrid
+ * @return void
+ */
+ public function __construct($gridData)
+ {
+ $this->gridData = $gridData;
+ }
+
+
+ public function view(): View
+ {
+ $results = $this->gridData->render();
+
+ $header = [];
+ foreach($results->columns as $col) {
+ $header[] = $col->label;
+ }
+
+ return view('admin::export.export', [
+ 'results' => $this->gridData->render()->results,
+ 'columns' => $this->gridData->render()->columns,
+ 'header' => $header
+ ]);
+ }
+}
\ No newline at end of file
diff --git a/packages/Webkul/Admin/src/Http/Controllers/Customer/CustomerController.php b/packages/Webkul/Admin/src/Http/Controllers/Customer/CustomerController.php
index 391620492..32ca24cfd 100644
--- a/packages/Webkul/Admin/src/Http/Controllers/Customer/CustomerController.php
+++ b/packages/Webkul/Admin/src/Http/Controllers/Customer/CustomerController.php
@@ -9,6 +9,10 @@ use Webkul\Customer\Repositories\CustomerRepository as Customer;
use Webkul\Customer\Repositories\CustomerGroupRepository as CustomerGroup;
use Webkul\Core\Repositories\ChannelRepository as Channel;
+use Webkul\Admin\DataGrids\CustomerDataGrid as CustomerDataGrid;
+use Webkul\Admin\Exports\DataGridExport;
+use Excel;
+
/**
* Customer controlller
*
@@ -45,15 +49,23 @@ class CustomerController extends Controller
*/
protected $channel;
+ /**
+ * CustomerDataGrid object
+ *
+ * @var array
+ */
+ protected $customerDataGrid;
+
/**
* Create a new controller instance.
*
* @param Webkul\Customer\Repositories\CustomerRepository as customer;
* @param Webkul\Customer\Repositories\CustomerGroupRepository as customerGroup;
* @param Webkul\Core\Repositories\ChannelRepository as Channel;
+ * @param Webkul\Admin\DataGrids\CustomerDataGrid as customerDataGrid;
* @return void
*/
- public function __construct(Customer $customer, CustomerGroup $customerGroup, Channel $channel )
+ public function __construct(Customer $customer, CustomerGroup $customerGroup, Channel $channel, CustomerDataGrid $customerDataGrid)
{
$this->_config = request('_config');
@@ -64,6 +76,9 @@ class CustomerController extends Controller
$this->customerGroup = $customerGroup;
$this->channel = $channel;
+
+ $this->customerDataGrid = $customerDataGrid;
+
}
/**
@@ -175,4 +190,15 @@ class CustomerController extends Controller
return redirect()->back();
}
+
+ /**
+ * function to export datagrid
+ *
+ */
+ public function export()
+ {
+ $data = $this->customerDataGrid;
+
+ return Excel::download(new DataGridExport($data), 'customers.xlsx');
+ }
}
diff --git a/packages/Webkul/Admin/src/Http/routes.php b/packages/Webkul/Admin/src/Http/routes.php
index 337d8a8fd..40d88800b 100644
--- a/packages/Webkul/Admin/src/Http/routes.php
+++ b/packages/Webkul/Admin/src/Http/routes.php
@@ -550,6 +550,9 @@ Route::group(['middleware' => ['web']], function () {
Route::get('/tax-rates/delete/{id}', 'Webkul\Tax\Http\Controllers\TaxRateController@destroy')->name('admin.tax-rates.delete');
//tax rate ends
+
+ //DataGrid Export
+ Route::get('export', 'Webkul\Admin\Http\Controllers\Customer\CustomerController@export')->name('admin.datagrid.export');
});
});
});
diff --git a/packages/Webkul/Admin/src/Resources/views/customers/index.blade.php b/packages/Webkul/Admin/src/Resources/views/customers/index.blade.php
index 03feb24cd..24027cadb 100644
--- a/packages/Webkul/Admin/src/Resources/views/customers/index.blade.php
+++ b/packages/Webkul/Admin/src/Resources/views/customers/index.blade.php
@@ -15,9 +15,16 @@
{{ __('admin::app.customers.customers.add-title') }}
+
+
+
+ Export
+
+
+
@inject('customer','Webkul\Admin\DataGrids\CustomerDataGrid')
{!! $customer->render() !!}
diff --git a/packages/Webkul/Admin/src/Resources/views/export/export.blade.php b/packages/Webkul/Admin/src/Resources/views/export/export.blade.php
new file mode 100644
index 000000000..6f3decab9
--- /dev/null
+++ b/packages/Webkul/Admin/src/Resources/views/export/export.blade.php
@@ -0,0 +1,18 @@
+
+
+
+ @foreach($header as $col)
+ | {{ $col}} |
+ @endforeach
+
+
+
+ @foreach ($results as $result)
+
+ @foreach ($columns as $column)
+ | {!! $column->render($result) !!} |
+ @endforeach
+
+ @endforeach
+
+
\ No newline at end of file
diff --git a/packages/Webkul/Product/src/Repositories/ProductReviewRepository.php b/packages/Webkul/Product/src/Repositories/ProductReviewRepository.php
index 1a4ec846c..8bfdd1eb4 100644
--- a/packages/Webkul/Product/src/Repositories/ProductReviewRepository.php
+++ b/packages/Webkul/Product/src/Repositories/ProductReviewRepository.php
@@ -55,7 +55,7 @@ class ProductReviewRepository extends Repository
{
$customerId = auth()->guard('customer')->user()->id;
- $reviews = $this->model->where(['customer_id'=> $customerId, 'status' => 'approved'])->with('product')->get();
+ $reviews = $this->model->where(['customer_id'=> $customerId])->with('product')->get();
return $reviews;
}
diff --git a/packages/Webkul/Shop/publishable/assets/mix-manifest.json b/packages/Webkul/Shop/publishable/assets/mix-manifest.json
index b7e923adb..8fb77ecfc 100644
--- a/packages/Webkul/Shop/publishable/assets/mix-manifest.json
+++ b/packages/Webkul/Shop/publishable/assets/mix-manifest.json
@@ -1,4 +1,16 @@
{
+<<<<<<< HEAD
"/js/shop.js": "/js/shop.js",
"/css/shop.css": "/css/shop.css"
}
+=======
+<<<<<<< HEAD
+ "/js/shop.js": "/js/shop.js",
+ "/css/shop.css": "/css/shop.css"
+}
+=======
+ "/js/shop.js": "/js/shop.js?id=c6ba9f43bd31f175a665",
+ "/css/shop.css": "/css/shop.css?id=2a9e3addb8dd8df86f03"
+}
+>>>>>>> 2a2b1e8ec4f3e110fca0b4926f090ed506b81ce5
+>>>>>>> master