export for customer
This commit is contained in:
commit
e1b2d1eb01
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
],
|
||||
];
|
||||
|
|
@ -0,0 +1,112 @@
|
|||
<?php
|
||||
|
||||
use Maatwebsite\Excel\Excel;
|
||||
|
||||
return [
|
||||
'exports' => [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| 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,
|
||||
],
|
||||
];
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Admin\Exports;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
|
||||
/**
|
||||
* DataGridExport class
|
||||
*
|
||||
* @author Rahul Shukla <rahulshukla.symfony517@webkul.com>
|
||||
* @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
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -15,9 +15,16 @@
|
|||
<a href="{{ route('admin.customer.create') }}" class="btn btn-lg btn-primary">
|
||||
{{ __('admin::app.customers.customers.add-title') }}
|
||||
</a>
|
||||
|
||||
|
||||
<a href="{{ route('admin.datagrid.export') }}" class="btn btn-lg btn-primary">
|
||||
Export
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="page-content">
|
||||
@inject('customer','Webkul\Admin\DataGrids\CustomerDataGrid')
|
||||
{!! $customer->render() !!}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
@foreach($header as $col)
|
||||
<th> {{ $col}} </th>
|
||||
@endforeach
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($results as $result)
|
||||
<tr>
|
||||
@foreach ($columns as $column)
|
||||
<td class="">{!! $column->render($result) !!}</td>
|
||||
@endforeach
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue