Merge branch 'development' of https://github.com/rahulshukla-webkul/bagisto into development
This commit is contained in:
commit
0fc78c5d83
|
|
@ -60,7 +60,9 @@
|
|||
"bagisto/laravel-tax": "v0.1.0",
|
||||
"bagisto/laravel-api": "v0.1.0",
|
||||
"bagisto/laravel-paypal": "v0.1.0",
|
||||
"bagisto/laravel-discount": "v0.1.0"
|
||||
"bagisto/laravel-discount": "v0.1.0",
|
||||
"bagisto/laravel-customer-document": "v0.1.0",
|
||||
"bagisto/laravel-bulk-add-to-cart": "v0.1.0"
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
|
|
@ -88,7 +90,9 @@
|
|||
"Webkul\\Sales\\": "packages/Webkul/Sales/src",
|
||||
"Webkul\\Tax\\": "packages/Webkul/Tax/src",
|
||||
"Webkul\\API\\": "packages/Webkul/API",
|
||||
"Webkul\\Discount\\": "packages/Webkul/Discount/src"
|
||||
"Webkul\\CustomerDocument\\": "packages/Webkul/CustomerDocument/src",
|
||||
"Webkul\\Discount\\": "packages/Webkul/Discount/src",
|
||||
"Webkul\\BulkAddToCart\\": "packages/Webkul/BulkAddToCart/src"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
|
|
|
|||
|
|
@ -245,7 +245,9 @@ return [
|
|||
Webkul\Sales\Providers\SalesServiceProvider::class,
|
||||
Webkul\Tax\Providers\TaxServiceProvider::class,
|
||||
Webkul\API\Providers\APIServiceProvider::class,
|
||||
Webkul\Discount\Providers\DiscountServiceProvider::class
|
||||
Webkul\CustomerDocument\Providers\CustomerDocumentServiceProvider::class,
|
||||
Webkul\Discount\Providers\DiscountServiceProvider::class,
|
||||
Webkul\BulkAddToCart\Providers\BulkAddToCartServiceProvider::class,
|
||||
],
|
||||
|
||||
/*
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"/js/admin.js": "/js/admin.js?id=f3dc175b3f211700d0fd",
|
||||
"/js/admin.js": "/js/admin.js?id=301713f31cb0ba5260b5",
|
||||
"/css/admin.css": "/css/admin.css?id=79d1d08f945a3e35e1c7"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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/laravel-bulk-add-to-cart",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Rahul Shukla",
|
||||
"email": "rahulshukla517@webkul.com"
|
||||
}
|
||||
],
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Webkul\\BulkAddToCart\\": "src/"
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Webkul\\BulkAddToCart\\BulkAddToCartServiceProvider"
|
||||
],
|
||||
"aliases": {}
|
||||
}
|
||||
},
|
||||
"minimum-stability": "dev"
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
[
|
||||
'key' => 'account.bulk-add-to-cart',
|
||||
'name' => 'bulkaddtocart::app.products.bulk-add-to-cart',
|
||||
'route' =>'cart.bulk-add-to-cart.create',
|
||||
'sort' => 7
|
||||
]
|
||||
];
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,163 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\BulkAddToCart\Http\Controllers;
|
||||
|
||||
use Webkul\Admin\Imports\DataGridImport;
|
||||
use Webkul\Product\Repositories\ProductRepository as Product;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Maatwebsite\Excel\Validators\Failure;
|
||||
use Excel;
|
||||
use Cart;
|
||||
|
||||
/**
|
||||
* BulkAddToCart controlller
|
||||
*
|
||||
* @author Rahul Shukla <rahulshukla.symfony517@webkul.com>
|
||||
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
|
||||
*/
|
||||
class BulkAddToCartController extends Controller
|
||||
{
|
||||
/**
|
||||
* Contains route related configuration
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_config;
|
||||
|
||||
/**
|
||||
* ProductRepository object
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $product;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @param \Webkul\Product\Repositories\ProductRepository $product
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Product $product)
|
||||
{
|
||||
$this->product = $product;
|
||||
|
||||
$this->_config = request('_config');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view($this->_config['view']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store()
|
||||
{
|
||||
$valid_extension = ['xlsx', 'csv', 'xls', 'ods'];
|
||||
|
||||
if (! in_array(request()->file('file')->getClientOriginalExtension(), $valid_extension)) {
|
||||
session()->flash('error', trans('bulkaddtocart::app.products.upload-error'));
|
||||
|
||||
return redirect()->back();
|
||||
} else {
|
||||
try {
|
||||
$excelData = (new DataGridImport)->toArray(request()->file('file'));
|
||||
$cart = [];
|
||||
|
||||
foreach ($excelData as $data) {
|
||||
foreach ($data as $column => $uploadData) {
|
||||
$validator = Validator::make($uploadData, [
|
||||
'sku' => 'required',
|
||||
'quantity' => 'required|numeric',
|
||||
]);
|
||||
|
||||
$product = $this->product->findOneWhere([
|
||||
'sku' => $uploadData['sku'],
|
||||
]);
|
||||
|
||||
if ($product) {
|
||||
$canAdd = $product->haveSufficientQuantity($uploadData['quantity']);
|
||||
|
||||
if (! $canAdd) {
|
||||
$sufficientQuantity[] = $column + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ($validator->fails()) {
|
||||
$failedRules[$column+1] = $validator->errors();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($failedRules)) {
|
||||
foreach ($failedRules as $coulmn => $fail) {
|
||||
if ($fail->first('sku')) {
|
||||
$errorMsg[$coulmn] = $fail->first('sku');
|
||||
} else if ($fail->first('quantity')) {
|
||||
$errorMsg[$coulmn] = $fail->first('quantity');
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($errorMsg as $key => $msg) {
|
||||
$msg = str_replace(".", "", $msg);
|
||||
$message[] = $msg. ' at Row ' .$key . '.';
|
||||
}
|
||||
|
||||
$finalMsg = implode(" ", $message);
|
||||
|
||||
session()->flash('error', $finalMsg);
|
||||
|
||||
return redirect()->back();
|
||||
} else if (isset($sufficientQuantity)) {
|
||||
$errorRows = implode(",", $sufficientQuantity);
|
||||
$finalMsg = trans('bulkaddtocart::app.products.quantity-error') . ' ' . $errorRows;
|
||||
|
||||
session()->flash('error', $finalMsg);
|
||||
|
||||
return redirect()->back();
|
||||
} else {
|
||||
foreach ($excelData as $data) {
|
||||
foreach ($data as $column => $uploadData) {
|
||||
$product = $this->product->findOneWhere([
|
||||
'sku' => $uploadData['sku'],
|
||||
]);
|
||||
|
||||
if ($product->type == 'simple') {
|
||||
$cart['product'] = (string)$product->id;
|
||||
$cart['quantity'] = (string)$uploadData['quantity'];
|
||||
$cart['is_configurable'] = 'false';
|
||||
|
||||
Event::fire('checkout.cart.add.before', $cart['product']);
|
||||
|
||||
$result = Cart::add($cart['product'], $cart);
|
||||
|
||||
Event::fire('checkout.cart.add.after', $result);
|
||||
|
||||
Cart::collectTotals();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
session()->flash('success', trans('bulkaddtocart::app.products.upload-sucess'));
|
||||
|
||||
return redirect()->route($this->_config['redirect']);
|
||||
} catch (\Exception $e) {
|
||||
$failure = new Failure(1, 'rows', [0 => trans('bulkaddtocart::app.products.enough-row-error')]);
|
||||
|
||||
session()->flash('error', $failure->errors()[0]);
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\BulkAddToCart\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,18 @@
|
|||
<?php
|
||||
|
||||
Route::group(['middleware' => ['web', 'locale', 'theme', 'currency']], function () {
|
||||
|
||||
Route::prefix('customer')->group(function () {
|
||||
|
||||
Route::group(['middleware' => ['customer']], function () {
|
||||
|
||||
Route::get('bulk-add-to-cart', 'Webkul\BulkAddToCart\Http\Controllers\BulkAddToCartController@create')->defaults('_config', [
|
||||
'view' => 'bulkaddtocart::products.bulk-add-to-cart'
|
||||
])->name('cart.bulk-add-to-cart.create');
|
||||
|
||||
Route::post('bulk-add-to-cart', 'Webkul\BulkAddToCart\Http\Controllers\BulkAddToCartController@store')->defaults('_config', [
|
||||
'redirect' => 'shop.checkout.cart.index'
|
||||
])->name('cart.bulk-add-to-cart.store');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\BulkAddToCart\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Routing\Router;
|
||||
|
||||
class BulkAddToCartServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot(Router $router)
|
||||
{
|
||||
$this->loadRoutesFrom(__DIR__ . '/../Http/routes.php');
|
||||
|
||||
$this->loadTranslationsFrom(__DIR__ . '/../Resources/lang', 'bulkaddtocart');
|
||||
|
||||
$this->loadViewsFrom(__DIR__ . '/../Resources/views', 'bulkaddtocart');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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,13 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
'products' => [
|
||||
'bulk-add-to-cart' => 'Bulk Add to Cart',
|
||||
'file' => 'File',
|
||||
'submit' => 'Submit',
|
||||
'upload-sucess' => 'Products Sucessfully added to Cart',
|
||||
'quantity-error' => 'Products have not sufficient quantity at row',
|
||||
'upload-error' => 'The file must be a file of type: xls, xlsx, csv, ods.',
|
||||
'enough-row-error' => 'file has not enough rows',
|
||||
],
|
||||
];
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
@extends('shop::layouts.master')
|
||||
|
||||
@section('page_title')
|
||||
{{ __('bulkaddtocart::app.products.bulk-add-to-cart') }}
|
||||
@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">{{ __('bulkaddtocart::app.products.bulk-add-to-cart') }}</span>
|
||||
|
||||
<div class="horizontal-rule"></div>
|
||||
</div>
|
||||
|
||||
<div class="account-items-list">
|
||||
<form method="POST" action="{{ route('cart.bulk-add-to-cart.store') }}" enctype="multipart/form-data" @submit.prevent="onSubmit">
|
||||
@csrf()
|
||||
|
||||
<div class="control-group" :class="[errors.has('file') ? 'has-error' : '']">
|
||||
<label for="file" class="required">{{ __('bulkaddtocart::app.products.file') }}</label>
|
||||
<input v-validate="'required'" type="file" class="control" id="file" name="file" data-vv-as=""{{ __('bulkaddtocart::app.products.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">
|
||||
{{ __('bulkaddtocart::app.products.submit') }}
|
||||
</button>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"name": "bagisto/laravel-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
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"/js/shop.js": "/js/shop.js?id=9a7027b387c171cd0fd3",
|
||||
"/css/shop.css": "/css/shop.css?id=5d0ffa213eda626b89f6"
|
||||
}
|
||||
"/js/shop.js": "/js/shop.js?id=71f03d05d9690fe24784",
|
||||
"/css/shop.css": "/css/shop.css?id=0e57754dbdaba7c6eb76"
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<!-- Generator: Sketch 51.1 (57501) - http://www.bohemiancoding.com/sketch -->
|
||||
<title>Icon-Note-Large</title>
|
||||
<desc>Created with Sketch.</desc>
|
||||
<defs></defs>
|
||||
<g id="Icon-Note-Large" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round">
|
||||
<g id="Group" transform="translate(3.000000, 3.000000)" stroke="#979797" stroke-width="2">
|
||||
<path d="M0,3 L18,3 L18,15 L12.5,15 C10.5,17 9.5,18 9.5,18 C9.5,18 8.33333333,17 6,15 L0,15 L0,3 Z" id="Rectangle-16"></path>
|
||||
<path d="M7,2.2522475 C7,0.997673883 8.09454039,4.04787445e-16 9.44472438,0 C10.7949084,-4.04787445e-16 11.8894488,0.997673883 11.8894488,2.22836699 L11.8894488,7.77163301 C11.8894488,9.00232612 10.7949084,10 9.44472438,10 C8.09454039,10 7,9.00232612 7,7.77163301 L7,6.80974897" id="Rectangle-17"></path>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
|
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="48px" height="48px" viewBox="0 0 48 48" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<!-- Generator: Sketch 51.1 (57501) - http://www.bohemiancoding.com/sketch -->
|
||||
<title>Icon-Promition-Active</title>
|
||||
<desc>Created with Sketch.</desc>
|
||||
<defs></defs>
|
||||
<g id="Icon-Promition-Active" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round">
|
||||
<g id="Group" transform="translate(8.000000, 10.000000)" stroke="#0041FF" stroke-width="2">
|
||||
<polygon id="Rectangle-15" points="5 8.96186626 22 1.91619318 22 26.0838068 5 19.0381337"></polygon>
|
||||
<path d="M22,0 L22,28" id="Path-17"></path>
|
||||
<path d="M3.5,9 L5,9 L5,19 L3.5,19 C1.56700338,19 2.36723813e-16,17.4329966 0,15.5 L0,12.5 C-2.36723813e-16,10.5670034 1.56700338,9 3.5,9 Z" id="Rectangle-15"></path>
|
||||
<path d="M8,21 L8,22.5494015 C8,24.2446714 9.1212786,25.7355564 10.75,26.2058824 L10.75,26.2058824 C12.3703103,26.6737794 14.1023615,25.9901587 14.9663265,24.5417467 L15.5,23.6470588" id="Path-18"></path>
|
||||
<path d="M26,14.25 L32,14.25" id="Path-19"></path>
|
||||
<path d="M26,9.24264069 L30.2426407,5" id="Path-19"></path>
|
||||
<path d="M26,23.1213203 L30.2426407,18.8786797" id="Path-19" transform="translate(28.121320, 21.000000) scale(-1, 1) translate(-28.121320, -21.000000) "></path>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
|
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="48px" height="48px" viewBox="0 0 48 48" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<!-- Generator: Sketch 51.1 (57501) - http://www.bohemiancoding.com/sketch -->
|
||||
<title>Icon-Promition</title>
|
||||
<desc>Created with Sketch.</desc>
|
||||
<defs></defs>
|
||||
<g id="Icon-Promition" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round">
|
||||
<g id="Group" transform="translate(8.000000, 10.000000)" stroke="#979797" stroke-width="2">
|
||||
<polygon id="Rectangle-15" points="5 8.96186626 22 1.91619318 22 26.0838068 5 19.0381337"></polygon>
|
||||
<path d="M22,0 L22,28" id="Path-17"></path>
|
||||
<path d="M3.5,9 L5,9 L5,19 L3.5,19 C1.56700338,19 2.36723813e-16,17.4329966 0,15.5 L0,12.5 C-2.36723813e-16,10.5670034 1.56700338,9 3.5,9 Z" id="Rectangle-15"></path>
|
||||
<path d="M8,21 L8,22.5494015 C8,24.2446714 9.1212786,25.7355564 10.75,26.2058824 L10.75,26.2058824 C12.3703103,26.6737794 14.1023615,25.9901587 14.9663265,24.5417467 L15.5,23.6470588" id="Path-18"></path>
|
||||
<path d="M26,14.25 L32,14.25" id="Path-19"></path>
|
||||
<path d="M26,9.24264069 L30.2426407,5" id="Path-19"></path>
|
||||
<path d="M26,23.1213203 L30.2426407,18.8786797" id="Path-19" transform="translate(28.121320, 21.000000) scale(-1, 1) translate(-28.121320, -21.000000) "></path>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
|
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"/js/ui.js": "/js/ui.js?id=97343143e38eeba34064",
|
||||
"/css/ui.css": "/css/ui.css?id=f912bd2a6525691bdb61"
|
||||
"/css/ui.css": "/css/ui.css?id=c846938a649c221ac297"
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue