customer document
This commit is contained in:
parent
dc96dfb7b2
commit
80ac7bba72
|
|
@ -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": {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
],
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -6,6 +6,9 @@
|
|||
|
||||
@section('content')
|
||||
<div class="content">
|
||||
|
||||
{!! view_render_event('bagisto.admin.customer.edit.before', ['customer' => $customer]) !!}
|
||||
|
||||
<form method="POST" action="{{ route('admin.customer.update', $customer->id) }}">
|
||||
|
||||
<div class="page-header">
|
||||
|
|
@ -117,5 +120,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
{!! view_render_event('bagisto.admin.customer.edit.after', ['customer' => $customer]) !!}
|
||||
</div>
|
||||
@stop
|
||||
|
|
@ -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"
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
[
|
||||
'key' => 'account.documents',
|
||||
'name' => 'customerdocument::app.admin.customers.documents',
|
||||
'route' =>'customer.documents.index',
|
||||
'sort' => 6
|
||||
]
|
||||
];
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\CustomerDocument\Contracts;
|
||||
|
||||
interface CustomerDocument
|
||||
{
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CustomerDocumentsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('customer_documents', function (Blueprint $table) {
|
||||
$table->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');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\CustomerDocument\Http\Controllers;
|
||||
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||
}
|
||||
|
|
@ -0,0 +1,112 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\CustomerDocument\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Webkul\CustomerDocument\Repositories\CustomerDocumentRepository;
|
||||
use Webkul\CustomerDocument\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
/**
|
||||
* Document controlller
|
||||
*
|
||||
* @author Rahul Shukla <rahulshukla.symfony517@webkul.com>
|
||||
* @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();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
Route::group(['middleware' => ['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');
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
Route::group(['middleware' => ['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');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\CustomerDocument\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Webkul\CustomerDocument\Contracts\CustomerDocument as CustomerDocumentContract;
|
||||
|
||||
class CustomerDocument extends Model implements CustomerDocumentContract
|
||||
{
|
||||
protected $table = 'customer_documents';
|
||||
|
||||
protected $fillable = ['name', 'path', 'customer_id'];
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\CustomerDocument\Models;
|
||||
|
||||
use Konekt\Concord\Proxies\ModelProxy;
|
||||
|
||||
class CustomerDocumentProxy extends ModelProxy
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\CustomerDocument\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Routing\Router;
|
||||
|
||||
class CustomerDocumentServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot(Router $router)
|
||||
{
|
||||
$this->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'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\CustomerDocument\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
|
||||
class EventServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
Event::listen('bagisto.admin.customer.edit.after', function($viewRenderEventManager) {
|
||||
$viewRenderEventManager->addTemplate('customerdocument::admin.customers.upload');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\CustomerDocument\Providers;
|
||||
|
||||
use Konekt\Concord\BaseModuleServiceProvider;
|
||||
|
||||
class ModuleServiceProvider extends BaseModuleServiceProvider
|
||||
{
|
||||
protected $models = [
|
||||
\Webkul\CustomerDocument\Models\CustomerDocument::class,
|
||||
];
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\CustomerDocument\Repositories;
|
||||
|
||||
use Webkul\Core\Eloquent\Repository;
|
||||
|
||||
/**
|
||||
* Customer Reposotory
|
||||
*
|
||||
* @author Rahul Shukla <rahulshukla517@webkul.com>
|
||||
* @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';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
'admin' =>[
|
||||
'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.'
|
||||
],
|
||||
],
|
||||
];
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
|
||||
$customerDocumentRepository = app('Webkul\CustomerDocument\Repositories\CustomerDocumentRepository');
|
||||
|
||||
$documents = $customerDocumentRepository->findWhere(['customer_id' => $customer->id]);
|
||||
|
||||
?>
|
||||
|
||||
<accordian :title="'{{ __('customerdocument::app.admin.customers.documents') }}'" :active="true">
|
||||
<div slot="body">
|
||||
|
||||
<button type="button" style="margin-bottom : 20px" class="btn btn-md btn-primary" @click="showModal('addDocument')">
|
||||
{{ __('customerdocument::app.admin.customers.add-document') }}
|
||||
</button>
|
||||
|
||||
<div class="table" style="margin-bottom: 20px;">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{ __('customerdocument::app.admin.customers.name') }}</th>
|
||||
<th>{{ __('customerdocument::app.admin.customers.download') }}</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
@foreach ($documents as $document)
|
||||
<tr>
|
||||
<td>{{ $document->name }}</td>
|
||||
<td>
|
||||
<a href="{{ route('admin.customer.document.download', $document->id) }}">
|
||||
<i class="icon sort-down-icon"></i>
|
||||
</a>
|
||||
</td>
|
||||
<td class="actions">
|
||||
<a href="{{ route('admin.customer.document.delete', $document->id) }}">
|
||||
<i class="icon trash-icon"></i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</accordian>
|
||||
|
||||
<modal id="addDocument" :is-open="modalIds.addDocument">
|
||||
<h3 slot="header">{{ __('customerdocument::app.admin.customers.add-document') }}</h3>
|
||||
|
||||
<div slot="body">
|
||||
<form method="POST" action="{{ route('admin.customer.document.upload') }}" enctype="multipart/form-data" @submit.prevent="onSubmit">
|
||||
@csrf()
|
||||
|
||||
<input type="hidden" name="customer_id" value="{{ $customer->id }}">
|
||||
|
||||
<div class="control-group" :class="[errors.has('name') ? 'has-error' : '']">
|
||||
<label for="name" class="required">{{ __('customerdocument::app.admin.customers.name') }}</label>
|
||||
<input v-validate="'required'" type="text" class="control" id="name" name="name" data-vv-as=""{{ __('customerdocument::app.admin.customers.name') }}"" value="{{ old('name') }}"/>
|
||||
<span class="control-error" v-if="errors.has('name')">@{{ errors.first('name') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="control-group" :class="[errors.has('file') ? 'has-error' : '']">
|
||||
<label for="file" class="required">{{ __('customerdocument::app.admin.customers.file') }}</label>
|
||||
<input v-validate="'required'" type="file" class="control" id="file" name="file" data-vv-as=""{{ __('customerdocument::app.admin.customers.file') }}"" value="{{ old('file') }}" style="padding-top: 5px">
|
||||
<span class="control-error" v-if="errors.has('file')">@{{ errors.first('file') }}</span>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-lg btn-primary">
|
||||
{{ __('customerdocument::app.admin.customers.submit') }}
|
||||
</button>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</modal>
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
@extends('shop::layouts.master')
|
||||
|
||||
@section('page_title')
|
||||
{{ __('customerdocument::app.admin.customers.documents') }}
|
||||
@endsection
|
||||
|
||||
@section('content-wrapper')
|
||||
|
||||
<div class="account-content">
|
||||
@include('shop::customers.account.partials.sidemenu')
|
||||
|
||||
<div class="account-layout">
|
||||
|
||||
<div class="account-head mb-15">
|
||||
<span class="account-heading">{{ __('customerdocument::app.admin.customers.documents') }}</span>
|
||||
|
||||
<div class="horizontal-rule"></div>
|
||||
</div>
|
||||
|
||||
<div class="account-items-list">
|
||||
@if ($documents->count())
|
||||
<div class="table" style="margin-bottom: 20px;">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{ __('customerdocument::app.admin.customers.name') }}</th>
|
||||
<th>{{ __('customerdocument::app.admin.customers.download') }}</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
@foreach ($documents as $document)
|
||||
<tr>
|
||||
<td>{{ $document->name }}</td>
|
||||
<td>
|
||||
<a href="{{ route('customer.document.download', $document->id) }}">
|
||||
<i class="icon sort-down-icon"></i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@else
|
||||
<div class="empty">
|
||||
{{ __('customerdocument::app.admin.customers.empty') }}
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
Loading…
Reference in New Issue