diff --git a/composer.json b/composer.json
index 0b5a05026..ef7ac4994 100755
--- a/composer.json
+++ b/composer.json
@@ -84,7 +84,8 @@
"Webkul\\Paypal\\": "packages/Webkul/Paypal/src",
"Webkul\\Sales\\": "packages/Webkul/Sales/src",
"Webkul\\Tax\\": "packages/Webkul/Tax/src",
- "Webkul\\API\\": "packages/Webkul/API"
+ "Webkul\\API\\": "packages/Webkul/API",
+ "Webkul\\CustomerDocument\\": "packages/Webkul/CustomerDocument/src"
}
},
"autoload-dev": {
diff --git a/config/app.php b/config/app.php
index edd6fd40b..7820f103c 100755
--- a/config/app.php
+++ b/config/app.php
@@ -245,6 +245,7 @@ return [
Webkul\Sales\Providers\SalesServiceProvider::class,
Webkul\Tax\Providers\TaxServiceProvider::class,
Webkul\API\Providers\APIServiceProvider::class,
+ Webkul\CustomerDocument\Providers\CustomerDocumentServiceProvider::class,
],
/*
diff --git a/packages/Webkul/Admin/src/Resources/views/customers/edit.blade.php b/packages/Webkul/Admin/src/Resources/views/customers/edit.blade.php
index a14dd01e0..aa476fb4a 100755
--- a/packages/Webkul/Admin/src/Resources/views/customers/edit.blade.php
+++ b/packages/Webkul/Admin/src/Resources/views/customers/edit.blade.php
@@ -6,6 +6,9 @@
@section('content')
+
+ {!! view_render_event('bagisto.admin.customer.edit.before', ['customer' => $customer]) !!}
+
+
+ {!! view_render_event('bagisto.admin.customer.edit.after', ['customer' => $customer]) !!}
@stop
\ No newline at end of file
diff --git a/packages/Webkul/CustomerDocument/composer.json b/packages/Webkul/CustomerDocument/composer.json
new file mode 100644
index 000000000..383539bb4
--- /dev/null
+++ b/packages/Webkul/CustomerDocument/composer.json
@@ -0,0 +1,24 @@
+{
+ "name": "bagisto/customer-document",
+ "license": "MIT",
+ "authors": [
+ {
+ "name": "Rahul Shukla",
+ "email": "rahulshukla517@webkul.com"
+ }
+ ],
+ "autoload": {
+ "psr-4": {
+ "Webkul\\CustomerDocument\\": "src/"
+ }
+ },
+ "extra": {
+ "laravel": {
+ "providers": [
+ "Webkul\\CustomerDocument\\CustomerDocumentServiceProvider"
+ ],
+ "aliases": {}
+ }
+ },
+ "minimum-stability": "dev"
+}
\ No newline at end of file
diff --git a/packages/Webkul/CustomerDocument/src/Config/menu.php b/packages/Webkul/CustomerDocument/src/Config/menu.php
new file mode 100644
index 000000000..b469239ea
--- /dev/null
+++ b/packages/Webkul/CustomerDocument/src/Config/menu.php
@@ -0,0 +1,12 @@
+ 'account.documents',
+ 'name' => 'customerdocument::app.admin.customers.documents',
+ 'route' =>'customer.documents.index',
+ 'sort' => 6
+ ]
+];
+
+?>
\ No newline at end of file
diff --git a/packages/Webkul/CustomerDocument/src/Contracts/CustomerDocument.php b/packages/Webkul/CustomerDocument/src/Contracts/CustomerDocument.php
new file mode 100644
index 000000000..44ca2e742
--- /dev/null
+++ b/packages/Webkul/CustomerDocument/src/Contracts/CustomerDocument.php
@@ -0,0 +1,7 @@
+increments('id');
+ $table->string('name');
+ $table->string('path');
+ $table->integer('customer_id')->unsigned();
+ $table->foreign('customer_id')->references('id')->on('customers')->onDelete('cascade');
+ $table->timestamps();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::dropIfExists('customer_documents');
+ }
+}
diff --git a/packages/Webkul/CustomerDocument/src/Http/Controllers/Controller.php b/packages/Webkul/CustomerDocument/src/Http/Controllers/Controller.php
new file mode 100644
index 000000000..ec04aa1e9
--- /dev/null
+++ b/packages/Webkul/CustomerDocument/src/Http/Controllers/Controller.php
@@ -0,0 +1,13 @@
+
+ * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
+ */
+class DocumentController extends Controller
+{
+ /**
+ * Contains route related configuration
+ *
+ * @var array
+ */
+ protected $_config;
+
+ /**
+ * CustomerDocumentRepository object
+ *
+ * @var array
+ */
+ protected $customerDocument;
+
+ /**
+ * Create a new controller instance.
+ *
+ * @param \Webkul\Customer\Repositories\CustomerDocumentRepository $customerDocument
+ */
+ public function __construct(CustomerDocumentRepository $customerDocument)
+ {
+ $this->_config = request('_config');
+
+ $this->customerDocument = $customerDocument;
+ }
+
+ /**
+ * Display a listing of the resource.
+ *
+ * @return \Illuminate\Http\Response
+ */
+ public function index()
+ {
+ $documents = $this->customerDocument->findWhere(['customer_id' => auth()->guard('customer')->user()->id]);
+
+ return view($this->_config['view'], compact('documents'));
+ }
+
+ /**
+ * upload document
+ *
+ * @return \Illuminate\Http\Response
+ */
+ public function upload()
+ {
+ $data = request()->all();
+
+ if (request()->hasFile('file')) {
+ $dir = 'customer';
+ $document['path'] = request()->file('file')->store($dir);
+ }
+
+ $document['customer_id'] = $data['customer_id'];
+ $document['name'] = $data['name'];
+
+ $this->customerDocument->create($document);
+
+ session()->flash('success', trans('customerdocument::app.admin.customers.upload-success'));
+
+ return redirect()->back();
+ }
+
+ /**
+ * download the file for the specified resource.
+ *
+ * @param int $id
+ * @return \Illuminate\Http\Response
+ */
+ public function download($id)
+ {
+ $document = $this->customerDocument->findOrfail($id);
+
+ return Storage::download($document['path']);
+ }
+
+ /**
+ * Remove the specified resource from storage..
+ *
+ * @param int $id
+ * @return \Illuminate\Http\Response
+ */
+ public function delete($id)
+ {
+ $document = $this->customerDocument->findOrfail($id);
+
+ $this->customerDocument->delete($id);
+
+ Storage::delete($document['path']);
+
+ session()->flash('success', trans('customerdocument::app.admin.customers.delete-success'));
+
+ return redirect()->back();
+ }
+}
\ No newline at end of file
diff --git a/packages/Webkul/CustomerDocument/src/Http/admin-routes.php b/packages/Webkul/CustomerDocument/src/Http/admin-routes.php
new file mode 100644
index 000000000..303622754
--- /dev/null
+++ b/packages/Webkul/CustomerDocument/src/Http/admin-routes.php
@@ -0,0 +1,26 @@
+ ['web']], function () {
+
+ Route::prefix('admin')->group(function () {
+
+ Route::group(['middleware' => ['admin']], function () {
+
+ //document Management Routes
+ Route::post('upload-document', 'Webkul\CustomerDocument\Http\Controllers\DocumentController@upload')->defaults('_config', [
+ 'redirect' => 'admin.customer.index'
+ ])->name('admin.customer.document.upload');
+
+ Route::get('download-document/{id}', 'Webkul\CustomerDocument\Http\Controllers\DocumentController@download')->defaults('_config', [
+ 'redirect' => 'admin.customer.index'
+ ])->name('admin.customer.document.download');
+
+ Route::get('delete-document/{id}', 'Webkul\CustomerDocument\Http\Controllers\DocumentController@delete')->defaults('_config', [
+ 'redirect' => 'admin.customer.index'
+ ])->name('admin.customer.document.delete');
+
+ });
+
+ });
+
+});
diff --git a/packages/Webkul/CustomerDocument/src/Http/front-routes.php b/packages/Webkul/CustomerDocument/src/Http/front-routes.php
new file mode 100644
index 000000000..51aa04022
--- /dev/null
+++ b/packages/Webkul/CustomerDocument/src/Http/front-routes.php
@@ -0,0 +1,21 @@
+ ['web', 'locale', 'theme', 'currency']], function () {
+
+ Route::prefix('customer')->group(function () {
+
+ Route::group(['middleware' => ['customer']], function () {
+
+ Route::prefix('account')->group(function () {
+
+ Route::get('documents', 'Webkul\CustomerDocument\Http\Controllers\DocumentController@index')->defaults('_config', [
+ 'view' => 'customerdocument::shop.customers.document'
+ ])->name('customer.documents.index');
+
+ Route::get('download-document/{id}', 'Webkul\CustomerDocument\Http\Controllers\DocumentController@download')->defaults('_config', [
+ 'redirect' => 'admin.customer.index'
+ ])->name('customer.document.download');
+ });
+ });
+ });
+});
\ No newline at end of file
diff --git a/packages/Webkul/CustomerDocument/src/Models/CustomerDocument.php b/packages/Webkul/CustomerDocument/src/Models/CustomerDocument.php
new file mode 100644
index 000000000..690f5d3a0
--- /dev/null
+++ b/packages/Webkul/CustomerDocument/src/Models/CustomerDocument.php
@@ -0,0 +1,13 @@
+loadRoutesFrom(__DIR__ . '/../Http/admin-routes.php');
+
+ $this->loadRoutesFrom(__DIR__ . '/../Http/front-routes.php');
+
+ $this->loadTranslationsFrom(__DIR__ . '/../Resources/lang', 'customerdocument');
+
+ $this->loadViewsFrom(__DIR__ . '/../Resources/views', 'customerdocument');
+
+ $this->loadMigrationsFrom(__DIR__ . '/../Database/migrations');
+
+ $this->app->register(ModuleServiceProvider::class);
+
+ $this->app->register(EventServiceProvider::class);
+ }
+
+ /**
+ * Register services.
+ *
+ * @return void
+ */
+ public function register()
+ {
+ $this->registerConfig();
+ }
+
+ /**
+ * Register package config.
+ *
+ * @return void
+ */
+ protected function registerConfig()
+ {
+ $this->mergeConfigFrom(
+ dirname(__DIR__) . '/Config/menu.php', 'menu.customer'
+ );
+ }
+}
\ No newline at end of file
diff --git a/packages/Webkul/CustomerDocument/src/Providers/EventServiceProvider.php b/packages/Webkul/CustomerDocument/src/Providers/EventServiceProvider.php
new file mode 100644
index 000000000..0feff68cc
--- /dev/null
+++ b/packages/Webkul/CustomerDocument/src/Providers/EventServiceProvider.php
@@ -0,0 +1,21 @@
+addTemplate('customerdocument::admin.customers.upload');
+ });
+ }
+}
\ No newline at end of file
diff --git a/packages/Webkul/CustomerDocument/src/Providers/ModuleServiceProvider.php b/packages/Webkul/CustomerDocument/src/Providers/ModuleServiceProvider.php
new file mode 100644
index 000000000..49aaf5ace
--- /dev/null
+++ b/packages/Webkul/CustomerDocument/src/Providers/ModuleServiceProvider.php
@@ -0,0 +1,12 @@
+
+ * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
+ */
+class CustomerDocumentRepository extends Repository
+{
+ /**
+ * Specify Model class name
+ *
+ * @return mixed
+ */
+
+ function model()
+ {
+ return 'Webkul\CustomerDocument\Contracts\CustomerDocument';
+ }
+}
\ No newline at end of file
diff --git a/packages/Webkul/CustomerDocument/src/Resources/lang/en/app.php b/packages/Webkul/CustomerDocument/src/Resources/lang/en/app.php
new file mode 100644
index 000000000..d7fbf56ac
--- /dev/null
+++ b/packages/Webkul/CustomerDocument/src/Resources/lang/en/app.php
@@ -0,0 +1,17 @@
+[
+ 'customers' => [
+ 'documents' => 'Documents',
+ 'add-document' => 'Add Document',
+ 'submit' => 'Submit',
+ 'file' => 'File',
+ 'name' => 'Name',
+ 'download' => 'Download',
+ 'upload-success' => 'Document uploaded successfully.',
+ 'delete-success' => 'Document deleted successfully.',
+ 'empty' => 'You Do not Have Any Documents.'
+ ],
+ ],
+];
\ No newline at end of file
diff --git a/packages/Webkul/CustomerDocument/src/Resources/views/admin/customers/upload.blade.php b/packages/Webkul/CustomerDocument/src/Resources/views/admin/customers/upload.blade.php
new file mode 100644
index 000000000..0d5235107
--- /dev/null
+++ b/packages/Webkul/CustomerDocument/src/Resources/views/admin/customers/upload.blade.php
@@ -0,0 +1,76 @@
+findWhere(['customer_id' => $customer->id]);
+
+?>
+
+
+ @include('shop::customers.account.partials.sidemenu')
+
+
+
+
+
{{ __('customerdocument::app.admin.customers.documents') }}
+
+
+
+
+
+ @if ($documents->count())
+
+
+
+
+ | {{ __('customerdocument::app.admin.customers.name') }} |
+ {{ __('customerdocument::app.admin.customers.download') }} |
+ |
+
+
+
+
+ @foreach ($documents as $document)
+
+ | {{ $document->name }} |
+
+
+
+
+ |
+
+ @endforeach
+
+
+
+ @else
+
+ {{ __('customerdocument::app.admin.customers.empty') }}
+
+ @endif
+
+
+
+
+@endsection
\ No newline at end of file