Merge branch 'master' of https://github.com/bagisto/bagisto into rahul

This commit is contained in:
rahul shukla 2018-12-26 14:47:50 +05:30
commit 1e25226997
63 changed files with 725 additions and 296 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
{ {
"/js/admin.js": "/js/admin.js?id=b77265f25dc2a33a4bb3", "/js/admin.js": "/js/admin.js?id=c70dacdf945a32e04b77",
"/css/admin.css": "/css/admin.css?id=ccb086d72702e662082e" "/css/admin.css": "/css/admin.css?id=ccb086d72702e662082e"
} }

View File

@ -150,22 +150,22 @@ class AttributeDataGrid
'type' => 'string', 'type' => 'string',
'label' => 'Type', 'label' => 'Type',
], [ ], [
'name' => 'is_required', 'column' => 'is_required',
'alias' => 'attributeIsRequired', 'alias' => 'attributeIsRequired',
'type' => 'boolean', 'type' => 'boolean',
'label' => 'Required', 'label' => 'Required',
], [ ], [
'name' => 'is_unique', 'column' => 'is_unique',
'alias' => 'attributeIsUnique', 'alias' => 'attributeIsUnique',
'type' => 'boolean', 'type' => 'boolean',
'label' => 'Unique', 'label' => 'Unique',
], [ ], [
'name' => 'value_per_locale', 'column' => 'value_per_locale',
'alias' => 'attributeValuePerLocale', 'alias' => 'attributeValuePerLocale',
'type' => 'boolean', 'type' => 'boolean',
'label' => 'Locale based', 'label' => 'Locale based',
], [ ], [
'name' => 'value_per_channel', 'column' => 'value_per_channel',
'alias' => 'attributeValuePerChannel', 'alias' => 'attributeValuePerChannel',
'type' => 'boolean', 'type' => 'boolean',
'label' => 'Channel based', 'label' => 'Channel based',

View File

@ -123,7 +123,7 @@ class ProductDataGrid
'type' => 'string', 'type' => 'string',
'label' => 'Product Quantity', 'label' => 'Product Quantity',
'sortable' => true, 'sortable' => true,
], ]
], ],
'filterable' => [ 'filterable' => [
@ -149,7 +149,7 @@ class ProductDataGrid
'type' => 'string', 'type' => 'string',
'label' => 'Product Type', 'label' => 'Product Type',
], [ ], [
'name' => 'prods.status', 'column' => 'prods.status',
'alias' => 'ProductStatus', 'alias' => 'ProductStatus',
'type' => 'boolean', 'type' => 'boolean',
'label' => 'Status' 'label' => 'Status'

View File

@ -4,6 +4,7 @@ namespace Webkul\Admin\Http\Controllers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\Response; use Illuminate\Http\Response;
use Illuminate\Support\Facades\Event;
use Webkul\Admin\Facades\Configuration; use Webkul\Admin\Facades\Configuration;
use Webkul\Core\Repositories\CoreConfigRepository as CoreConfig; use Webkul\Core\Repositories\CoreConfigRepository as CoreConfig;
use Webkul\Core\Tree; use Webkul\Core\Tree;
@ -130,8 +131,12 @@ class ConfigurationController extends Controller
*/ */
public function store() public function store()
{ {
Event::fire('core.configuration.save.after');
$this->coreConfig->create(request()->all()); $this->coreConfig->create(request()->all());
Event::fire('core.configuration.save.after');
session()->flash('success', 'Shipping Method is created successfully'); session()->flash('success', 'Shipping Method is created successfully');
return redirect()->back(); return redirect()->back();

View File

@ -324,6 +324,10 @@ Route::group(['middleware' => ['web']], function () {
//delete backend user //delete backend user
Route::get('/users/delete/{id}', 'Webkul\User\Http\Controllers\UserController@destroy')->name('admin.users.delete'); Route::get('/users/delete/{id}', 'Webkul\User\Http\Controllers\UserController@destroy')->name('admin.users.delete');
Route::post('/confirm/destroy', 'Webkul\User\Http\Controllers\UserController@destroySelf')->defaults('_config', [
'redirect' => 'admin.users.index'
])->name('admin.users.confirm.destroy');
// User Role Routes // User Role Routes
Route::get('/roles', 'Webkul\User\Http\Controllers\RoleController@index')->defaults('_config', [ Route::get('/roles', 'Webkul\User\Http\Controllers\RoleController@index')->defaults('_config', [
'view' => 'admin::users.roles.index' 'view' => 'admin::users.roles.index'

View File

@ -25,7 +25,7 @@ class Order {
try { try {
Mail::send(new NewOrderNotification($order)); Mail::send(new NewOrderNotification($order));
} catch (\Exception $e) { } catch (\Exception $e) {
} }
} }
@ -39,7 +39,7 @@ class Order {
try { try {
Mail::send(new NewInvoiceNotification($invoice)); Mail::send(new NewInvoiceNotification($invoice));
} catch (\Exception $e) { } catch (\Exception $e) {
} }
} }
@ -53,7 +53,7 @@ class Order {
try { try {
Mail::send(new NewShipmentNotification($shipment)); Mail::send(new NewShipmentNotification($shipment));
} catch (\Exception $e) { } catch (\Exception $e) {
} }
} }
@ -67,7 +67,7 @@ class Order {
$productListener = app(\Webkul\Admin\Listeners\Product::class); $productListener = app(\Webkul\Admin\Listeners\Product::class);
foreach ($order->items as $item) { foreach ($order->items as $item) {
$productListener->afterProductCreated($item->product); $productListener->afterOrderRecieved($item->product->id, $item->qty_ordered);
} }
} }
} }

View File

@ -73,24 +73,29 @@ class Product {
$variants = []; $variants = [];
$this->productGrid->create($gridObject); $found = $this->productGrid->findOneByField('product_id', $product->id);
if($product->type == 'configurable') { //extra measure to stop duplicate entries
$variants = $product->variants()->get(); if($found == null) {
$this->productGrid->create($gridObject);
foreach($variants as $variant) { if($product->type == 'configurable') {
$variantObj = [ $variants = $product->variants()->get();
'product_id' => $variant->id,
'sku' => $variant->sku,
'type' => $variant->type,
'attribute_family_name' => $variant->toArray()['attribute_family']['name'],
'name' => $variant->name,
'quantity' => 0,
'status' => $variant->status,
'price' => $variant->price,
];
$this->productGrid->create($variantObj); foreach($variants as $variant) {
$variantObj = [
'product_id' => $variant->id,
'sku' => $variant->sku,
'type' => $variant->type,
'attribute_family_name' => $variant->toArray()['attribute_family']['name'],
'name' => $variant->name,
'quantity' => 0,
'status' => $variant->status,
'price' => $variant->price,
];
$this->productGrid->create($variantObj);
}
} }
} }
@ -213,6 +218,20 @@ class Product {
return true; return true;
} }
/**
* Updates the product quantity when the order is received
*
* @param $productId
* @param $itemQuantity
*/
public function afterOrderRecieved($productId, $itemQuantity) {
$productGrid = $this->productGrid->findOneByField('product_id', $productId);
$productGrid->update(['quantity' => $productGrid->quantity - $itemQuantity]);
return true;
}
/** /**
* Manually invoke this function when you have created the products by importing or seeding or factory. * Manually invoke this function when you have created the products by importing or seeding or factory.
*/ */
@ -254,6 +273,13 @@ class Product {
$gridObject = []; $gridObject = [];
} }
$this->findRepeated();
return true; return true;
} }
public function findRepeated() {
}
} }

View File

@ -35,6 +35,8 @@ class AdminServiceProvider extends ServiceProvider
$this->composeView(); $this->composeView();
$this->registerACL();
$this->app->register(EventServiceProvider::class); $this->app->register(EventServiceProvider::class);
$this->app->bind( $this->app->bind(
@ -87,17 +89,44 @@ class AdminServiceProvider extends ServiceProvider
}); });
view()->composer(['admin::users.roles.create', 'admin::users.roles.edit'], function ($view) { view()->composer(['admin::users.roles.create', 'admin::users.roles.edit'], function ($view) {
$tree = Tree::create(); $view->with('acl', $this->createACL());
foreach(config('acl') as $item) {
$tree->add($item);
}
$tree->items = core()->sortItems($tree->items);
$view->with('acl', $tree);
}); });
} }
/**
* Registers acl to entire application
*
* @return void
*/
public function registerACL()
{
$this->app->singleton('acl', function () {
return $this->createACL();
});
}
/**
* Create acl tree
*
* @return mixed
*/
public function createACL()
{
static $tree;
if($tree)
return $tree;
$tree = Tree::create();
foreach(config('acl') as $item) {
$tree->add($item, 'acl');
}
$tree->items = core()->sortItems($tree->items);
return $tree;
}
/** /**
* Register package config. * Register package config.

View File

@ -21,5 +21,13 @@ class EventServiceProvider extends ServiceProvider
Event::listen('checkout.invoice.save.after', 'Webkul\Admin\Listeners\Order@sendNewShipmentMail'); Event::listen('checkout.invoice.save.after', 'Webkul\Admin\Listeners\Order@sendNewShipmentMail');
Event::listen('checkout.order.save.after', 'Webkul\Admin\Listeners\Order@updateProductInventory'); Event::listen('checkout.order.save.after', 'Webkul\Admin\Listeners\Order@updateProductInventory');
Event::listen('products.datagrid.sync', 'Webkul\Admin\Listeners\Product@sync');
Event::listen('catalog.product.create.after', 'Webkul\Admin\Listeners\Product@afterProductCreated');
Event::listen('catalog.product.update.after', 'Webkul\Admin\Listeners\Product@afterProductUpdate');
Event::listen('catalog.product.delete.after', 'Webkul\Admin\Listeners\Product@afterProductDelete');
} }
} }

View File

@ -50,6 +50,7 @@ return [
'change-password' => 'Change Account Password', 'change-password' => 'Change Account Password',
'current-password' => 'Current Password' 'current-password' => 'Current Password'
], ],
'users' => [ 'users' => [
'forget-password' => [ 'forget-password' => [
'title' => 'Forget Password', 'title' => 'Forget Password',
@ -60,6 +61,7 @@ return [
'back-link-title' => 'Back to Sign In', 'back-link-title' => 'Back to Sign In',
'submit-btn-title' => 'Email Password Reset Link' 'submit-btn-title' => 'Email Password Reset Link'
], ],
'reset-password' => [ 'reset-password' => [
'title' => 'Reset Password', 'title' => 'Reset Password',
'title' => 'Reset Password', 'title' => 'Reset Password',
@ -69,6 +71,7 @@ return [
'back-link-title' => 'Back to Sign In', 'back-link-title' => 'Back to Sign In',
'submit-btn-title' => 'Reset Password' 'submit-btn-title' => 'Reset Password'
], ],
'roles' => [ 'roles' => [
'title' => 'Roles', 'title' => 'Roles',
'add-role-title' => 'Add Role', 'add-role-title' => 'Add Role',
@ -82,6 +85,7 @@ return [
'custom' => 'Custom', 'custom' => 'Custom',
'all' => 'All' 'all' => 'All'
], ],
'users' => [ 'users' => [
'title' => 'User', 'title' => 'User',
'add-user-title' => 'Add User', 'add-user-title' => 'Add User',
@ -95,8 +99,15 @@ return [
'status-and-role' => 'Status and Role', 'status-and-role' => 'Status and Role',
'role' => 'Role', 'role' => 'Role',
'status' => 'Status', 'status' => 'Status',
'account-is-active' => 'Account is Active' 'account-is-active' => 'Account is Active',
'current-password' => 'Enter Current Password',
'confirm-delete' => 'Confirm Delete This Account',
'confirm-delete-title' => 'Confirm password before delete',
'delete-last' => 'At least one admin is required.',
'delete-success' => 'Success! User deleted',
'incorrect-password' => 'The password you entered is incorrect'
], ],
'sessions' => [ 'sessions' => [
'title' => 'Sign In', 'title' => 'Sign In',
'email' => 'Email', 'email' => 'Email',
@ -106,6 +117,7 @@ return [
'submit-btn-title' => 'Sign In' 'submit-btn-title' => 'Sign In'
] ]
], ],
'sales' => [ 'sales' => [
'orders' => [ 'orders' => [
'title' => 'Orders', 'title' => 'Orders',
@ -157,6 +169,7 @@ return [
'total-due' => 'Total Due', 'total-due' => 'Total Due',
'cancel-confirm-msg' => 'Are you sure you want to cancel this order ?' 'cancel-confirm-msg' => 'Are you sure you want to cancel this order ?'
], ],
'invoices' => [ 'invoices' => [
'title' => 'Invoices', 'title' => 'Invoices',
'id' => 'Id', 'id' => 'Id',
@ -178,6 +191,7 @@ return [
'print' => 'Print', 'print' => 'Print',
'order-date' => 'Order Date' 'order-date' => 'Order Date'
], ],
'shipments' => [ 'shipments' => [
'title' => 'Shipments', 'title' => 'Shipments',
'id' => 'Id', 'id' => 'Id',
@ -196,6 +210,7 @@ return [
'view-title' => 'Shipment #:shipment_id', 'view-title' => 'Shipment #:shipment_id',
] ]
], ],
'catalog' => [ 'catalog' => [
'products' => [ 'products' => [
'title' => 'Products', 'title' => 'Products',
@ -227,8 +242,10 @@ return [
'add-variant-title' => 'Add Variant', 'add-variant-title' => 'Add Variant',
'variant-already-exist-message' => 'Variant with same attribute options already exists.', 'variant-already-exist-message' => 'Variant with same attribute options already exists.',
'add-image-btn-title' => 'Add Image', 'add-image-btn-title' => 'Add Image',
'mass-delete-success' => 'All the selected index of products have been deleted successfully' 'mass-delete-success' => 'All the selected index of products have been deleted successfully',
'mass-update-success' => 'All the selected index of products have been updated successfully'
], ],
'attributes' => [ 'attributes' => [
'title' => 'Attributes', 'title' => 'Attributes',
'add-title' => 'Add Attribute', 'add-title' => 'Add Attribute',

View File

@ -128,7 +128,7 @@
<label for="validation">{{ __('admin::app.catalog.attributes.input_validation') }}</label> <label for="validation">{{ __('admin::app.catalog.attributes.input_validation') }}</label>
<select class="control" id="validation" name="validation"> <select class="control" id="validation" name="validation">
<option value=""></option> <option value=""></option>
<option value="numeric" {{ $selectedValidation == 'number' ? 'selected' : '' }}> <option value="numeric" {{ $selectedValidation == 'numeric' ? 'selected' : '' }}>
{{ __('admin::app.catalog.attributes.number') }} {{ __('admin::app.catalog.attributes.number') }}
</option> </option>
<option value="decimal" {{ $selectedValidation == 'decimal' ? 'selected' : '' }}> <option value="decimal" {{ $selectedValidation == 'decimal' ? 'selected' : '' }}>

View File

@ -92,7 +92,7 @@
{{ $attribute->admin_name }} {{ $attribute->admin_name }}
@if ($attribute->type == 'price') @if ($attribute->type == 'price')
<span class="currency-code">({{ currency()->symbol(core()->getBaseCurrencyCode()) }})</span> <span class="currency-code">({{ core()->currencySymbol(core()->getBaseCurrencyCode()) }})</span>
@endif @endif
<?php <?php

View File

@ -0,0 +1,37 @@
@extends('admin::layouts.content')
@section('page_title')
{{ __('admin::app.customers.customers.title') }}
@stop
@section('content')
<div class="content">
<div class="page-header">
<div class="page-title">
<h1>{{ __('admin::app.users.users.confirm-delete-title') }}</h1>
</div>
<div class="page-action">
</div>
</div>
<div class="page-content">
<form action="{{ route('admin.users.confirm.destroy') }}" method="POST" @submit.prevent="onSubmit">
@csrf
<div class="control-group" :class="[errors.has('password') ? 'has-error' : '']">
<label for="password" class="required">
{{ __('admin::app.users.users.current-password') }}
</label>
<input type="password" v-validate="'required'" class="control" id="password" name="password" data-vv-as="&quot;{{ __('admin::app.users.users.password') }}&quot;"/>
<span class="control-error" v-if="errors.has('password')">
@{{ errors.first('password') }}
</span>
</div>
<input type="submit" class="btn btn-md btn-primary" value="{{ __('admin::app.users.users.confirm-delete') }}">
</form>
</div>
</div>
@endsection

View File

@ -30,6 +30,9 @@
<div class="dropdown-container"> <div class="dropdown-container">
<label>Account</label> <label>Account</label>
<ul> <ul>
<li>
<a href="{{ route('shop.home.index') }}" target="_blank">Visit Shop</a>
</li>
<li> <li>
<a href="{{ route('admin.account.edit') }}">My Account</a> <a href="{{ route('admin.account.edit') }}">My Account</a>
</li> </li>

View File

@ -1,8 +1,8 @@
const { mix } = require("laravel-mix"); const { mix } = require("laravel-mix");
require("laravel-mix-merge-manifest"); require("laravel-mix-merge-manifest");
var publicPath = 'publishable/assets'; // var publicPath = 'publishable/assets';
// var publicPath = "../../../public/vendor/webkul/admin/assets"; var publicPath = "../../../public/vendor/webkul/admin/assets";
mix.setPublicPath(publicPath).mergeManifest(); mix.setPublicPath(publicPath).mergeManifest();
mix.disableNotifications(); mix.disableNotifications();

View File

@ -4,6 +4,7 @@ namespace Webkul\Attribute\Http\Controllers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\Response; use Illuminate\Http\Response;
use Illuminate\Support\Facades\Event;
use Webkul\Attribute\Repositories\AttributeRepository as Attribute; use Webkul\Attribute\Repositories\AttributeRepository as Attribute;
@ -77,7 +78,11 @@ class AttributeController extends Controller
'type' => 'required' 'type' => 'required'
]); ]);
$this->attribute->create(request()->all()); Event::fire('catalog.attribute.create.before');
$attribute = $this->attribute->create(request()->all());
Event::fire('catalog.attribute.create.after', $attribute);
session()->flash('success', 'Attribute created successfully.'); session()->flash('success', 'Attribute created successfully.');
@ -112,7 +117,11 @@ class AttributeController extends Controller
'type' => 'required' 'type' => 'required'
]); ]);
$this->attribute->update(request()->all(), $id); Event::fire('catalog.attribute.update.before', $id);
$attribute = $this->attribute->update(request()->all(), $id);
Event::fire('catalog.attribute.update.after', $attribute);
session()->flash('success', 'Attribute updated successfully.'); session()->flash('success', 'Attribute updated successfully.');
@ -133,8 +142,12 @@ class AttributeController extends Controller
session()->flash('error', 'Can not delete system attribute.'); session()->flash('error', 'Can not delete system attribute.');
} else { } else {
try { try {
Event::fire('catalog.attribute.delete.before', $id);
$this->attribute->delete($id); $this->attribute->delete($id);
Event::fire('catalog.attribute.delete.after', $id);
session()->flash('success', 'Attribute deleted successfully.'); session()->flash('success', 'Attribute deleted successfully.');
} catch(\Exception $e) { } catch(\Exception $e) {
session()->flash('error', 'Attribute is used in configurable products.'); session()->flash('error', 'Attribute is used in configurable products.');
@ -159,10 +172,15 @@ class AttributeController extends Controller
$attribute = $this->attribute->findOrFail($value); $attribute = $this->attribute->findOrFail($value);
try { try {
if(!$attribute->is_user_defined) if(!$attribute->is_user_defined) {
continue; continue;
else } else {
Event::fire('catalog.attribute.delete.before', $value);
$this->attribute->delete($value); $this->attribute->delete($value);
Event::fire('catalog.attribute.delete.after', $value);
}
} catch(\Exception $e) { } catch(\Exception $e) {
$suppressFlash = true; $suppressFlash = true;

View File

@ -4,6 +4,7 @@ namespace Webkul\Attribute\Http\Controllers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\Response; use Illuminate\Http\Response;
use Illuminate\Support\Facades\Event;
use Webkul\Attribute\Repositories\AttributeFamilyRepository as AttributeFamily; use Webkul\Attribute\Repositories\AttributeFamilyRepository as AttributeFamily;
use Webkul\Attribute\Repositories\AttributeRepository as Attribute; use Webkul\Attribute\Repositories\AttributeRepository as Attribute;
@ -82,7 +83,11 @@ class AttributeFamilyController extends Controller
'name' => 'required' 'name' => 'required'
]); ]);
$this->attributeFamily->create(request()->all()); Event::fire('catalog.attribute_family.create.before');
$attributeFamily = $this->attributeFamily->create(request()->all());
Event::fire('catalog.attribute_family.create.after', $attributeFamily);
session()->flash('success', 'Family created successfully.'); session()->flash('success', 'Family created successfully.');
@ -119,8 +124,11 @@ class AttributeFamilyController extends Controller
'name' => 'required' 'name' => 'required'
]); ]);
Event::fire('catalog.attribute_family.update.before', $id);
$this->attributeFamily->update(request()->all(), $id); $attributeFamily = $this->attributeFamily->update(request()->all(), $id);
Event::fire('catalog.attribute_family.update.after', $attributeFamily);
session()->flash('success', 'Family updated successfully.'); session()->flash('success', 'Family updated successfully.');
@ -142,8 +150,12 @@ class AttributeFamilyController extends Controller
} else if ($attributeFamily->products()->count()) { } else if ($attributeFamily->products()->count()) {
session()->flash('error', 'Attribute family is used in products.'); session()->flash('error', 'Attribute family is used in products.');
} else { } else {
Event::fire('catalog.attribute_family.delete.before', $id);
$this->attributeFamily->delete($id); $this->attributeFamily->delete($id);
Event::fire('catalog.attribute_family.delete.after', $id);
session()->flash('success', 'Family deleted successfully.'); session()->flash('success', 'Family deleted successfully.');
} }
@ -163,7 +175,11 @@ class AttributeFamilyController extends Controller
foreach($indexes as $key => $value) { foreach($indexes as $key => $value) {
try { try {
Event::fire('catalog.attribute_family.delete.before', $value);
$this->attributeFamily->delete($value); $this->attributeFamily->delete($value);
Event::fire('catalog.attribute_family.delete.after', $value);
} catch(\Exception $e) { } catch(\Exception $e) {
$suppressFlash = true; $suppressFlash = true;

View File

@ -4,6 +4,7 @@ namespace Webkul\Category\Http\Controllers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\Response; use Illuminate\Http\Response;
use Illuminate\Support\Facades\Event;
use Webkul\Category\Repositories\CategoryRepository as Category; use Webkul\Category\Repositories\CategoryRepository as Category;
/** /**
@ -74,10 +75,15 @@ class CategoryController extends Controller
{ {
$this->validate(request(), [ $this->validate(request(), [
'slug' => ['required', 'unique:category_translations,slug', new \Webkul\Core\Contracts\Validations\Slug], 'slug' => ['required', 'unique:category_translations,slug', new \Webkul\Core\Contracts\Validations\Slug],
'name' => 'required' 'name' => 'required',
'image.*' => 'mimes:jpeg,jpg,bmp,png'
]); ]);
$this->category->create(request()->all()); Event::fire('catalog.category.create.before');
$category = $this->category->create(request()->all());
Event::fire('catalog.category.create.after', $category);
session()->flash('success', 'Category created successfully.'); session()->flash('success', 'Category created successfully.');
@ -109,6 +115,7 @@ class CategoryController extends Controller
public function update(Request $request, $id) public function update(Request $request, $id)
{ {
$locale = request()->get('locale') ?: app()->getLocale(); $locale = request()->get('locale') ?: app()->getLocale();
$this->validate(request(), [ $this->validate(request(), [
$locale . '.slug' => ['required', new \Webkul\Core\Contracts\Validations\Slug, function ($attribute, $value, $fail) use ($id) { $locale . '.slug' => ['required', new \Webkul\Core\Contracts\Validations\Slug, function ($attribute, $value, $fail) use ($id) {
if (!$this->category->isSlugUnique($id, $value)) { if (!$this->category->isSlugUnique($id, $value)) {
@ -116,10 +123,15 @@ class CategoryController extends Controller
} }
}], }],
$locale . '.name' => 'required', $locale . '.name' => 'required',
'image.*' => 'mimes:jpeg,jpg,bmp,png'
]); ]);
Event::fire('catalog.category.update.before', $id);
$this->category->update(request()->all(), $id); $this->category->update(request()->all(), $id);
Event::fire('catalog.category.update.after', $id);
session()->flash('success', 'Category updated successfully.'); session()->flash('success', 'Category updated successfully.');
return redirect()->route($this->_config['redirect']); return redirect()->route($this->_config['redirect']);
@ -133,8 +145,12 @@ class CategoryController extends Controller
*/ */
public function destroy($id) public function destroy($id)
{ {
Event::fire('catalog.category.delete.before', $id);
$this->category->delete($id); $this->category->delete($id);
Event::fire('catalog.category.delete.after', $id);
session()->flash('success', 'Category deleted successfully.'); session()->flash('success', 'Category deleted successfully.');
return redirect()->back(); return redirect()->back();
@ -153,7 +169,11 @@ class CategoryController extends Controller
foreach($indexes as $key => $value) { foreach($indexes as $key => $value) {
try { try {
Event::fire('catalog.category.delete.before', $value);
$this->category->delete($value); $this->category->delete($value);
Event::fire('catalog.category.delete.after', $value);
} catch(\Exception $e) { } catch(\Exception $e) {
$suppressFlash = true; $suppressFlash = true;

View File

@ -639,9 +639,16 @@ class Cart {
} }
} }
$cart->customer_email = $cart->shipping_address->email; if(auth()->guard('customer')->check()) {
$cart->customer_first_name = $cart->shipping_address->first_name; $cart->customer_email = auth()->guard('customer')->user()->email;
$cart->customer_last_name = $cart->shipping_address->last_name; $cart->customer_first_name = auth()->guard('customer')->user()->first_name;
$cart->customer_last_name = auth()->guard('customer')->user()->last_name;
} else {
$cart->customer_email = $cart->billing_address->email;
$cart->customer_first_name = $cart->billing_address->first_name;
$cart->customer_last_name = $cart->billing_address->last_name;
}
$cart->save(); $cart->save();
return true; return true;

View File

@ -339,7 +339,7 @@ class Core
if (null === $exchangeRate) if (null === $exchangeRate)
return $amount; return $amount;
return (float) round($amount * $exchangeRate->rate); return (float) $amount * $exchangeRate->rate;
} }
/** /**
@ -358,6 +358,21 @@ class Core
return currency($this->convertPrice($amount), $currencyCode); return currency($this->convertPrice($amount), $currencyCode);
} }
/**
* Return currency symbol from currency code
*
* @param float $price
* @return string
*/
public function currencySymbol($code)
{
try {
return currency()->symbol($code);
} catch (\Exception $e) {
return $code;
}
}
/** /**
* Format and convert price with currency symbol * Format and convert price with currency symbol
* *

View File

@ -0,0 +1,33 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AlterChannelsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('channels', function (Blueprint $table) {
$table->dropForeign('channels_default_locale_id_foreign');
$table->dropForeign('channels_base_currency_id_foreign');
$table->foreign('default_locale_id')->references('id')->on('locales');
$table->foreign('base_currency_id')->references('id')->on('currencies');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}

View File

@ -4,6 +4,7 @@ namespace Webkul\Core\Http\Controllers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\Response; use Illuminate\Http\Response;
use Illuminate\Support\Facades\Event;
use Webkul\Core\Repositories\ChannelRepository as Channel; use Webkul\Core\Repositories\ChannelRepository as Channel;
@ -77,10 +78,16 @@ class ChannelController extends Controller
'locales' => 'required|array|min:1', 'locales' => 'required|array|min:1',
'default_locale_id' => 'required', 'default_locale_id' => 'required',
'currencies' => 'required|array|min:1', 'currencies' => 'required|array|min:1',
'base_currency_id' => 'required' 'base_currency_id' => 'required',
'logo.*' => 'mimes:jpeg,jpg,bmp,png',
'favicon.*' => 'mimes:jpeg,jpg,bmp,png'
]); ]);
$this->channel->create(request()->all()); Event::fire('core.channel.create.before');
$channel = $this->channel->create(request()->all());
Event::fire('core.channel.create.after', $channel);
session()->flash('success', 'Channel created successfully.'); session()->flash('success', 'Channel created successfully.');
@ -115,10 +122,16 @@ class ChannelController extends Controller
'locales' => 'required|array|min:1', 'locales' => 'required|array|min:1',
'default_locale_id' => 'required', 'default_locale_id' => 'required',
'currencies' => 'required|array|min:1', 'currencies' => 'required|array|min:1',
'base_currency_id' => 'required' 'base_currency_id' => 'required',
'logo.*' => 'mimes:jpeg,jpg,bmp,png',
'favicon.*' => 'mimes:jpeg,jpg,bmp,png'
]); ]);
$this->channel->update(request()->all(), $id); Event::fire('core.channel.update.before', $id);
$channel = $this->channel->update(request()->all(), $id);
Event::fire('core.channel.update.after', $channel);
session()->flash('success', 'Channel updated successfully.'); session()->flash('success', 'Channel updated successfully.');
@ -136,8 +149,12 @@ class ChannelController extends Controller
if($this->channel->count() == 1) { if($this->channel->count() == 1) {
session()->flash('error', 'At least one channel is required.'); session()->flash('error', 'At least one channel is required.');
} else { } else {
Event::fire('core.channel.delete.before', $id);
$this->channel->delete($id); $this->channel->delete($id);
Event::fire('core.channel.delete.after', $id);
session()->flash('success', 'Channel deleted successfully.'); session()->flash('success', 'Channel deleted successfully.');
} }

View File

@ -56,7 +56,8 @@ class CountryStateController extends Controller
* *
* @return array * @return array
*/ */
public function getCountries() { public function getCountries()
{
$countries = $this->country->all(); $countries = $this->country->all();
$states = $this->state->all(); $states = $this->state->all();
@ -73,7 +74,8 @@ class CountryStateController extends Controller
return view($this->_config['view'])->with('statesCountries', $nestedArray); return view($this->_config['view'])->with('statesCountries', $nestedArray);
} }
public function getStates($country) { public function getStates($country)
{
$countries = $this->country->all(); $countries = $this->country->all();
$states = $this->state->all(); $states = $this->state->all();

View File

@ -4,6 +4,7 @@ namespace Webkul\Core\Http\Controllers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\Response; use Illuminate\Http\Response;
use Illuminate\Support\Facades\Event;
use Webkul\Core\Repositories\CurrencyRepository as Currency; use Webkul\Core\Repositories\CurrencyRepository as Currency;
/** /**
@ -76,7 +77,11 @@ class CurrencyController extends Controller
'name' => 'required' 'name' => 'required'
]); ]);
$this->currency->create(request()->all()); Event::fire('core.channel.create.before');
$currency = $this->currency->create(request()->all());
Event::fire('core.currency.create.after', $currency);
session()->flash('success', 'Currency created successfully.'); session()->flash('success', 'Currency created successfully.');
@ -110,7 +115,11 @@ class CurrencyController extends Controller
'name' => 'required' 'name' => 'required'
]); ]);
$this->currency->update(request()->all(), $id); Event::fire('core.currency.update.before', $id);
$currency = $this->currency->update(request()->all(), $id);
Event::fire('core.currency.update.after', $currency);
session()->flash('success', 'Currency updated successfully.'); session()->flash('success', 'Currency updated successfully.');
@ -125,12 +134,20 @@ class CurrencyController extends Controller
*/ */
public function destroy($id) public function destroy($id)
{ {
$result = $this->currency->delete($id); try {
Event::fire('core.currency.delete.before', $id);
if($result) $result = $this->currency->delete($id);
session()->flash('success', 'Currency deleted successfully.');
else Event::fire('core.currency.delete.after', $id);
session()->flash('error', 'At least one currency is required.');
if($result)
session()->flash('success', 'Currency deleted successfully.');
else
session()->flash('error', 'At least one currency is required.');
} catch (\Exception $e) {
session()->flash('error', $e->getMessage());
}
return redirect()->back(); return redirect()->back();
} }
@ -148,7 +165,11 @@ class CurrencyController extends Controller
foreach($indexes as $key => $value) { foreach($indexes as $key => $value) {
try { try {
Event::fire('core.currency.delete.before', $value);
$this->currency->delete($value); $this->currency->delete($value);
Event::fire('core.currency.delete.after', $value);
} catch(\Exception $e) { } catch(\Exception $e) {
$suppressFlash = true; $suppressFlash = true;

View File

@ -4,6 +4,7 @@ namespace Webkul\Core\Http\Controllers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\Response; use Illuminate\Http\Response;
use Illuminate\Support\Facades\Event;
use Webkul\Core\Repositories\ExchangeRateRepository as ExchangeRate; use Webkul\Core\Repositories\ExchangeRateRepository as ExchangeRate;
use Webkul\Core\Repositories\CurrencyRepository as Currency; use Webkul\Core\Repositories\CurrencyRepository as Currency;
@ -89,7 +90,11 @@ class ExchangeRateController extends Controller
'rate' => 'required|numeric' 'rate' => 'required|numeric'
]); ]);
$this->exchangeRate->create(request()->all()); Event::fire('core.exchange_rate.create.before');
$exchangeRate = $this->exchangeRate->create(request()->all());
Event::fire('core.exchange_rate.create.after', $exchangeRate);
session()->flash('success', 'Exchange rate created successfully.'); session()->flash('success', 'Exchange rate created successfully.');
@ -125,7 +130,11 @@ class ExchangeRateController extends Controller
'rate' => 'required|numeric' 'rate' => 'required|numeric'
]); ]);
$this->exchangeRate->update(request()->all(), $id); Event::fire('core.exchange_rate.update.before', $id);
$exchangeRate = $this->exchangeRate->update(request()->all(), $id);
Event::fire('core.exchange_rate.update.after', $exchangeRate);
session()->flash('success', 'Exchange rate updated successfully.'); session()->flash('success', 'Exchange rate updated successfully.');
@ -143,8 +152,12 @@ class ExchangeRateController extends Controller
if($this->exchangeRate->count() == 1) { if($this->exchangeRate->count() == 1) {
session()->flash('error', 'At least one Exchange rate is required.'); session()->flash('error', 'At least one Exchange rate is required.');
} else { } else {
Event::fire('core.exchange_rate.delete.before', $id);
$this->exchangeRate->delete($id); $this->exchangeRate->delete($id);
Event::fire('core.exchange_rate.delete.after', $id);
session()->flash('success', 'Exchange rate deleted successfully.'); session()->flash('success', 'Exchange rate deleted successfully.');
} }

View File

@ -4,6 +4,7 @@ namespace Webkul\Core\Http\Controllers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\Response; use Illuminate\Http\Response;
use Illuminate\Support\Facades\Event;
use Webkul\Core\Repositories\LocaleRepository as Locale; use Webkul\Core\Repositories\LocaleRepository as Locale;
/** /**
@ -76,7 +77,11 @@ class LocaleController extends Controller
'name' => 'required' 'name' => 'required'
]); ]);
$this->locale->create(request()->all()); Event::fire('core.locale.create.before');
$locale = $this->locale->create(request()->all());
Event::fire('core.locale.create.after', $locale);
session()->flash('success', 'Locale created successfully.'); session()->flash('success', 'Locale created successfully.');
@ -110,7 +115,11 @@ class LocaleController extends Controller
'name' => 'required' 'name' => 'required'
]); ]);
$this->locale->update(request()->all(), $id); Event::fire('core.locale.update.before', $id);
$locale = $this->locale->update(request()->all(), $id);
Event::fire('core.locale.update.after', $locale);
session()->flash('success', 'Locale updated successfully.'); session()->flash('success', 'Locale updated successfully.');
@ -128,8 +137,12 @@ class LocaleController extends Controller
if($this->locale->count() == 1) { if($this->locale->count() == 1) {
session()->flash('error', 'At least one locale is required.'); session()->flash('error', 'At least one locale is required.');
} else { } else {
Event::fire('core.locale.delete.before', $id);
$this->locale->delete($id); $this->locale->delete($id);
Event::fire('core.locale.delete.after', $id);
session()->flash('success', 'Locale deleted successfully.'); session()->flash('success', 'Locale deleted successfully.');
} }

View File

@ -19,6 +19,13 @@ class Tree {
*/ */
public $items = []; public $items = [];
/**
* Contains acl roles
*
* @var array
*/
public $roles = [];
/** /**
* Contains current item route * Contains current item route
* *
@ -74,11 +81,14 @@ class Tree {
if (strpos($this->current, $item['url']) !== false) { if (strpos($this->current, $item['url']) !== false) {
$this->currentKey = $item['key']; $this->currentKey = $item['key'];
} }
} else if ($type == 'acl') {
$this->roles[$item['route']] = $item['key'];
} }
$children = str_replace('.', '.children.', $item['key']); $children = str_replace('.', '.children.', $item['key']);
core()->array_set($this->items, $children, $item); core()->array_set($this->items, $children, $item);
} }
/** /**

View File

@ -4,6 +4,7 @@ namespace Webkul\Customer\Http\Controllers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\Response; use Illuminate\Http\Response;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Mail; use Illuminate\Support\Facades\Mail;
use Webkul\Customer\Mail\VerificationEmail; use Webkul\Customer\Mail\VerificationEmail;
use Illuminate\Routing\Controller; use Illuminate\Routing\Controller;
@ -29,7 +30,8 @@ class RegistrationController extends Controller
/** /**
* @param CustomerRepository object $customer * @param CustomerRepository object $customer
*/ */
public function __construct(CustomerRepository $customer) { public function __construct(CustomerRepository $customer)
{
$this->_config = request('_config'); $this->_config = request('_config');
$this->customer = $customer; $this->customer = $customer;
} }
@ -39,7 +41,8 @@ class RegistrationController extends Controller
* *
* @return view * @return view
*/ */
public function show() { public function show()
{
return view($this->_config['view']); return view($this->_config['view']);
} }
@ -48,7 +51,8 @@ class RegistrationController extends Controller
* *
* @return Mixed * @return Mixed
*/ */
public function create(Request $request) { public function create(Request $request)
{
$request->validate([ $request->validate([
'first_name' => 'string|required', 'first_name' => 'string|required',
'last_name' => 'string|required', 'last_name' => 'string|required',
@ -70,9 +74,14 @@ class RegistrationController extends Controller
$verificationData['email'] = $data['email']; $verificationData['email'] = $data['email'];
$verificationData['token'] = md5(uniqid(rand(), true)); $verificationData['token'] = md5(uniqid(rand(), true));
$data['token'] = $verificationData['token']; $data['token'] = $verificationData['token'];
$created = $this->customer->create($data);
if ($created) { Event::fire('customer.registration.before');
$customer = $this->customer->create($data);
Event::fire('customer.registration.after', $customer);
if ($customer) {
try { try {
session()->flash('success', trans('shop::app.customer.signup-form.success')); session()->flash('success', trans('shop::app.customer.signup-form.success'));
@ -94,8 +103,10 @@ class RegistrationController extends Controller
/** /**
* Method to verify account * Method to verify account
* *
* @param string $token
*/ */
public function verifyAccount($token) { public function verifyAccount($token)
{
$customer = $this->customer->findOneByField('token', $token); $customer = $this->customer->findOneByField('token', $token);
if($customer) { if($customer) {
@ -109,7 +120,8 @@ class RegistrationController extends Controller
return redirect()->route('customer.session.index'); return redirect()->route('customer.session.index');
} }
public function resendVerificationEmail($email) { public function resendVerificationEmail($email)
{
$verificationData['email'] = $email; $verificationData['email'] = $email;
$verificationData['token'] = md5(uniqid(rand(), true)); $verificationData['token'] = md5(uniqid(rand(), true));

View File

@ -10,7 +10,6 @@ use Webkul\Core\Eloquent\Repository;
* @author Prashant Singh <prashant.singh852@webkul.com> * @author Prashant Singh <prashant.singh852@webkul.com>
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/ */
class CustomerRepository extends Repository class CustomerRepository extends Repository
{ {
/** /**
@ -23,32 +22,4 @@ class CustomerRepository extends Repository
{ {
return 'Webkul\Customer\Models\Customer'; return 'Webkul\Customer\Models\Customer';
} }
/**
* @param array $data
* @return mixed
*/
public function create(array $data)
{
$customer = $this->model->create($data);
return $customer;
}
/**
* @param array $data
* @param $id
* @param string $attribute
* @return mixed
*/
public function update(array $data, $id, $attribute = "id")
{
$customer = $this->find($id);
$customer->update($data);
return $customer;
}
} }

View File

@ -4,6 +4,7 @@ namespace Webkul\Inventory\Http\Controllers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\Response; use Illuminate\Http\Response;
use Illuminate\Support\Facades\Event;
use Webkul\Inventory\Repositories\InventorySourceRepository as InventorySource; use Webkul\Inventory\Repositories\InventorySourceRepository as InventorySource;
/** /**
@ -85,7 +86,11 @@ class InventorySourceController extends Controller
$data['status'] = !isset($data['status']) ? 0 : 1; $data['status'] = !isset($data['status']) ? 0 : 1;
$this->inventorySource->create($data); Event::fire('inventory.inventory_source.create.before');
$inventorySource = $this->inventorySource->create($data);
Event::fire('inventory.inventory_source.create.after', $inventorySource);
session()->flash('success', 'Inventory source created successfully.'); session()->flash('success', 'Inventory source created successfully.');
@ -131,7 +136,11 @@ class InventorySourceController extends Controller
$data['status'] = !isset($data['status']) ? 0 : 1; $data['status'] = !isset($data['status']) ? 0 : 1;
$this->inventorySource->update($data, $id); Event::fire('inventory.inventory_source.update.before', $id);
$inventorySource = $this->inventorySource->update($data, $id);
Event::fire('inventory.inventory_source.update.after', $inventorySource);
session()->flash('success', 'Inventory source updated successfully.'); session()->flash('success', 'Inventory source updated successfully.');
@ -149,8 +158,12 @@ class InventorySourceController extends Controller
if($this->inventorySource->count() == 1) { if($this->inventorySource->count() == 1) {
session()->flash('error', 'At least one inventory source is required.'); session()->flash('error', 'At least one inventory source is required.');
} else { } else {
Event::fire('inventory.inventory_source.delete.before', $id);
$this->inventorySource->delete($id); $this->inventorySource->delete($id);
Event::fire('inventory.inventory_source.delete.after', $id);
session()->flash('success', 'Inventory source deleted successfully.'); session()->flash('success', 'Inventory source deleted successfully.');
} }

View File

@ -4,13 +4,13 @@ namespace Webkul\Product\Http\Controllers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\Response; use Illuminate\Http\Response;
use Illuminate\Support\Facades\Event;
use Webkul\Product\Http\Requests\ProductForm; use Webkul\Product\Http\Requests\ProductForm;
use Webkul\Product\Repositories\ProductRepository as Product; use Webkul\Product\Repositories\ProductRepository as Product;
use Webkul\Product\Repositories\ProductGridRepository as ProductGrid; use Webkul\Product\Repositories\ProductGridRepository as ProductGrid;
use Webkul\Attribute\Repositories\AttributeFamilyRepository as AttributeFamily; use Webkul\Attribute\Repositories\AttributeFamilyRepository as AttributeFamily;
use Webkul\Category\Repositories\CategoryRepository as Category; use Webkul\Category\Repositories\CategoryRepository as Category;
use Webkul\Inventory\Repositories\InventorySourceRepository as InventorySource; use Webkul\Inventory\Repositories\InventorySourceRepository as InventorySource;
use Event;
/** /**
* Product controller * Product controller
@ -126,9 +126,6 @@ class ProductController extends Controller
*/ */
public function store() public function store()
{ {
//before store of the product
// Event::fire('product.save.before', false);
if(!request()->get('family') && request()->input('type') == 'configurable' && request()->input('sku') != '') { if(!request()->get('family') && request()->input('type') == 'configurable' && request()->input('sku') != '') {
return redirect(url()->current() . '?family=' . request()->input('attribute_family_id') . '&sku=' . request()->input('sku')); return redirect(url()->current() . '?family=' . request()->input('attribute_family_id') . '&sku=' . request()->input('sku'));
} }
@ -145,10 +142,13 @@ class ProductController extends Controller
'sku' => ['required', 'unique:products,sku', new \Webkul\Core\Contracts\Validations\Slug] 'sku' => ['required', 'unique:products,sku', new \Webkul\Core\Contracts\Validations\Slug]
]); ]);
//before store of the product
Event::fire('catalog.product.create.before');
$product = $this->product->create(request()->all()); $product = $this->product->create(request()->all());
//after store of the product //after store of the product
Event::fire('product.save.after', $product); Event::fire('catalog.product.create.after', $product);
session()->flash('success', 'Product created successfully.'); session()->flash('success', 'Product created successfully.');
@ -181,13 +181,11 @@ class ProductController extends Controller
*/ */
public function update(ProductForm $request, $id) public function update(ProductForm $request, $id)
{ {
// before update of product Event::fire('catalog.product.update.before', $id);
// Event::fire('product.update.before', $id);
$product = $this->product->update(request()->all(), $id); $product = $this->product->update(request()->all(), $id);
//after update of product Event::fire('catalog.product.update.after', $product);
Event::fire('product.update.after', $product);
session()->flash('success', 'Product updated successfully.'); session()->flash('success', 'Product updated successfully.');
@ -202,12 +200,11 @@ class ProductController extends Controller
*/ */
public function destroy($id) public function destroy($id)
{ {
Event::fire('product.delete.before', $id); Event::fire('catalog.product.delete.before', $id);
$this->product->delete($id); $this->product->delete($id);
//before update of product Event::fire('catalog.product.delete.after', $id);
// Event::fire('product.delete.after', $id);
session()->flash('success', 'Product deleted successfully.'); session()->flash('success', 'Product deleted successfully.');
@ -228,7 +225,11 @@ class ProductController extends Controller
$product = $this->product->find($productId); $product = $this->product->find($productId);
if(!is_null($product)) { if(!is_null($product)) {
Event::fire('catalog.product.delete.before', $productId);
$product->delete(); $product->delete();
Event::fire('catalog.product.delete.after', $productId);
} }
} }
} }
@ -258,11 +259,15 @@ class ProductController extends Controller
$product = $this->product->find($productId); $product = $this->product->find($productId);
if($data['update-options'] == 0 && $data['selected-option-text'] == 'In Active') { if($data['update-options'] == 0 && $data['selected-option-text'] == 'In Active') {
Event::fire('catelog.product.update.before', $productId);
$result = $this->product->updateAttribute($product, $attribute, $data['update-options']); $result = $this->product->updateAttribute($product, $attribute, $data['update-options']);
if($result) if($result)
Event::fire('product.update.after', $product); Event::fire('catelog.product.update.after', $product);
} else if($data['update-options'] == 1 && $data['selected-option-text'] == 'Active') { } else if($data['update-options'] == 1 && $data['selected-option-text'] == 'Active') {
Event::fire('catelog.product.update.before', $productId);
$result = $this->product->updateAttribute($product, $attribute, $data['update-options']); $result = $this->product->updateAttribute($product, $attribute, $data['update-options']);
if($result) if($result)
@ -271,7 +276,7 @@ class ProductController extends Controller
} }
} }
session()->flash('success', trans('admin::app.catalog.products.mass-delete-success')); session()->flash('success', trans('admin::app.catalog.products.mass-update-success'));
return redirect()->route($this->_config['redirect']); return redirect()->route($this->_config['redirect']);
} }

View File

@ -4,6 +4,7 @@ namespace Webkul\Product\Http\Controllers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\Response; use Illuminate\Http\Response;
use Illuminate\Support\Facades\Event;
use Webkul\Product\Repositories\ProductRepository as Product; use Webkul\Product\Repositories\ProductRepository as Product;
use Webkul\Product\Repositories\ProductReviewRepository as ProductReview; use Webkul\Product\Repositories\ProductReviewRepository as ProductReview;
@ -85,8 +86,12 @@ class ReviewController extends Controller
*/ */
public function update(Request $request, $id) public function update(Request $request, $id)
{ {
Event::fire('customer.review.update.before', $id);
$this->productReview->update(request()->all(), $id); $this->productReview->update(request()->all(), $id);
Event::fire('customer.review.update.after', $id);
session()->flash('success', 'Review updated successfully.'); session()->flash('success', 'Review updated successfully.');
return redirect()->route($this->_config['redirect']); return redirect()->route($this->_config['redirect']);
@ -100,8 +105,12 @@ class ReviewController extends Controller
*/ */
public function destroy($id) public function destroy($id)
{ {
Event::fire('customer.review.delete.before', $id);
$this->productReview->delete($id); $this->productReview->delete($id);
Event::fire('customer.review.delete.after', $id);
session()->flash('success', 'Review Successfully Deleted'); session()->flash('success', 'Review Successfully Deleted');
return redirect()->back(); return redirect()->back();
@ -122,7 +131,11 @@ class ReviewController extends Controller
foreach($indexes as $key => $value) { foreach($indexes as $key => $value) {
try { try {
Event::fire('customer.review.delete.before', $value);
$this->productReview->delete($value); $this->productReview->delete($value);
Event::fire('customer.review.delete.after', $value);
} catch(\Exception $e) { } catch(\Exception $e) {
$suppressFlash = true; $suppressFlash = true;
@ -162,7 +175,11 @@ class ReviewController extends Controller
try { try {
if($data['massaction-type'] == 1 && $data['update-options'] == 1 && $data['selected-option-text'] == 'Approve') { if($data['massaction-type'] == 1 && $data['update-options'] == 1 && $data['selected-option-text'] == 'Approve') {
Event::fire('customer.review.update.before', $value);
$review->update(['status' => 'approved']); $review->update(['status' => 'approved']);
Event::fire('customer.review.update.after', $review);
} else if($data['massaction-type'] == 1 && $data['update-options'] == 0 && $data['selected-option-text'] == 'Disapprove') { } else if($data['massaction-type'] == 1 && $data['update-options'] == 0 && $data['selected-option-text'] == 'Disapprove') {
$review->update(['status' => 'pending']); $review->update(['status' => 'pending']);
} else { } else {

View File

@ -1,41 +0,0 @@
<?php
namespace Webkul\Product\Observers;
use Webkul\Product\Models\Product;
class ProductObserver
{
/**
* Handle to the product "created" event.
*
* @param \App\Product $product
* @return void
*/
public function created(Product $product)
{
}
/**
* Handle the product "updated" event.
*
* @param \App\Product $product
* @return void
*/
public function updated(Product $product)
{
//
}
/**
* Handle the product "deleted" event.
*
* @param \App\Product $product
* @return void
*/
public function deleted(Product $product)
{
//
}
}

View File

@ -5,8 +5,6 @@ namespace Webkul\Product\Providers;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
use Illuminate\Routing\Router; use Illuminate\Routing\Router;
use Webkul\Product\Models\Product; use Webkul\Product\Models\Product;
use Webkul\Product\Observers\ProductObserver;
use Event;
class ProductServiceProvider extends ServiceProvider class ProductServiceProvider extends ServiceProvider
{ {
@ -18,20 +16,6 @@ class ProductServiceProvider extends ServiceProvider
public function boot(Router $router) public function boot(Router $router)
{ {
$this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations'); $this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations');
Event::listen('products.datagrid.sync', 'Webkul\Admin\Listeners\Product@sync');
Event::listen('product.save.after', 'Webkul\Admin\Listeners\Product@afterProductCreated');
Event::listen('product.update.before',
'Webkul\Admin\Listeners\Product@beforeProductUpdate');
Event::listen('product.update.after',
'Webkul\Admin\Listeners\Product@afterProductUpdate');
Event::listen('product.delete.after', 'Webkul\Admin\Listeners\Product@afterProductDelete');
Product::observe(ProductObserver::class);
} }
/** /**

View File

@ -38,10 +38,12 @@ class ProductImageRepository extends Repository
$dir = 'product/' . $product->id; $dir = 'product/' . $product->id;
if (str_contains($imageId, 'image_')) { if (str_contains($imageId, 'image_')) {
$this->create([ if(request()->hasFile($file)) {
'path' => request()->file($file)->store($dir), $this->create([
'product_id' => $product->id 'path' => request()->file($file)->store($dir),
]); 'product_id' => $product->id
]);
}
} else { } else {
if(is_numeric($index = $previousImageIds->search($imageId))) { if(is_numeric($index = $previousImageIds->search($imageId))) {
$previousImageIds->forget($index); $previousImageIds->forget($index);

View File

@ -61,6 +61,26 @@ return [
'type' => 'textarea', 'type' => 'textarea',
'channel_based' => true, 'channel_based' => true,
'locale_based' => false 'locale_based' => false
], [
'name' => 'default_rate',
'title' => 'Rate',
'type' => 'text',
'channel_based' => true,
'locale_based' => false
], [
'name' => 'type',
'title' => 'Type',
'type' => 'select',
'options' => [
[
'title' => 'Per Unit',
'value' => 'Per Order'
], [
'title' => 'Inactive',
'value' => 'per_order'
]
],
'validation' => 'required'
], [ ], [
'name' => 'active', 'name' => 'active',
'title' => 'Status', 'title' => 'Status',

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
{ {
"/js/shop.js": "/js/shop.js?id=c6ba9f43bd31f175a665", "/js/shop.js": "/js/shop.js?id=dc2ea56a854d779e7089",
"/css/shop.css": "/css/shop.css?id=44608a4ce1658811733f" "/css/shop.css": "/css/shop.css?id=7c64b6577e4bcb5b03ee"
} }

View File

@ -26,7 +26,13 @@ return [
'name' => 'Wishlist', 'name' => 'Wishlist',
'route' =>'customer.wishlist.index', 'route' =>'customer.wishlist.index',
'sort' => 4 'sort' => 4
], [
'key' => 'account.orders',
'name' => 'Orders',
'route' =>'customer.orders.index',
'sort' => 5
] ]
]; ];
?> ?>

View File

@ -57,7 +57,7 @@ class SliderController extends controller
$this->validate(request(), [ $this->validate(request(), [
'title' => 'string|required', 'title' => 'string|required',
'channel_id' => 'required', 'channel_id' => 'required',
'image' => 'required', 'image' => 'required|mimes:jpeg,bmp,png'
]); ]);
$result = $this->slider->save(request()->all()); $result = $this->slider->save(request()->all());
@ -90,6 +90,7 @@ class SliderController extends controller
$this->validate(request(), [ $this->validate(request(), [
'title' => 'string|required', 'title' => 'string|required',
'channel_id' => 'required', 'channel_id' => 'required',
'image' => 'sometimes|mimes:jpeg,bmp,png'
]); ]);
$result = $this->slider->updateItem(request()->all(), $id); $result = $this->slider->updateItem(request()->all(), $id);

View File

@ -84,9 +84,9 @@ class SubscriptionController extends Controller
$mailSent = true; $mailSent = true;
try { try {
session()->flash('success', trans('shop::app.subscription.subscribed'));
Mail::send(new SubscriptionEmail($subscriptionData)); Mail::send(new SubscriptionEmail($subscriptionData));
session()->flash('success', trans('shop::app.subscription.subscribed'));
} catch(\Exception $e) { } catch(\Exception $e) {
session()->flash('error', trans('shop::app.subscription.not-subscribed')); session()->flash('error', trans('shop::app.subscription.not-subscribed'));

View File

@ -17,6 +17,10 @@ $(document).ready(function () {
const app = new Vue({ const app = new Vue({
el: "#app", el: "#app",
data: {
modalIds: {}
},
mounted: function () { mounted: function () {
this.addServerErrors(); this.addServerErrors();
this.addFlashMessages(); this.addFlashMessages();
@ -79,7 +83,11 @@ $(document).ready(function () {
}, this); }, this);
}, },
responsiveHeader: function () { } responsiveHeader: function () { },
showModal(id) {
this.$set(this.modalIds, id, true);
}
} }
}); });
}); });

View File

@ -25,6 +25,10 @@ body {
font-family: "Montserrat", sans-serif; font-family: "Montserrat", sans-serif;
} }
textarea {
resize: none;
}
input { input {
font-family: 'Montserrat', sans-serif; font-family: 'Montserrat', sans-serif;
} }
@ -334,6 +338,10 @@ input {
justify-content: center; justify-content: center;
} }
.grid-container {
margin-top: 20px;
}
//main store front layouting //main store front layouting
.main-container-wrapper { .main-container-wrapper {
max-width: 1300px; max-width: 1300px;
@ -448,7 +456,11 @@ input {
} }
.product-card:hover { .product-card:hover {
box-shadow: 1px 1px 10px #ccc; outline: 1px solid #eaeaec;
box-shadow: 0 1px 2px rgba(0,0,0,0.05);
-webkit-box-shadow: 0px 2px 16px 4px rgba(40, 44, 63, 0.07);
-moz-box-shadow: 0px 2px 16px 4px rgba(40, 44, 63, 0.07);
box-shadow: 0px 2px 16px 4px rgba(40, 44, 63, 0.07);
} }
@media only screen and (max-width: 580px) { @media only screen and (max-width: 580px) {

View File

@ -286,7 +286,7 @@ return [
'newest-first' => 'Newest First', 'newest-first' => 'Newest First',
'oldest-first' => 'Oldest First', 'oldest-first' => 'Oldest First',
'cheapest-first' => 'Cheapest First', 'cheapest-first' => 'Cheapest First',
'expensive-first' => 'Expensive First', 'expansive-first' => 'Expensive First',
'show' => 'Show', 'show' => 'Show',
'pager-info' => 'Showing :showing of :total Items', 'pager-info' => 'Showing :showing of :total Items',
'description' => 'Description', 'description' => 'Description',

View File

@ -22,7 +22,7 @@
<div class="dropdown-header"> <div class="dropdown-header">
<p class="heading"> <p class="heading">
{{ __('shop::app.checkout.cart.cart-subtotal') }} - {{ __('shop::app.checkout.cart.cart-subtotal') }} -
{{ core()->currency($cart->sub_total) }} {{ core()->currency($cart->base_sub_total) }}
</p> </p>
</div> </div>
@ -53,7 +53,7 @@
</div> </div>
@endif @endif
<div class="item-price">{{ core()->currency($item->total) }}</div> <div class="item-price">{{ core()->currency($item->base_total) }}</div>
<div class="item-qty">Quantity - {{ $item->quantity }}</div> <div class="item-qty">Quantity - {{ $item->quantity }}</div>
</div> </div>

View File

@ -7,7 +7,7 @@
{{ __('shop::app.checkout.total.sub-total') }} {{ __('shop::app.checkout.total.sub-total') }}
{{ __('shop::app.checkout.total.price') }} {{ __('shop::app.checkout.total.price') }}
</label> </label>
<label class="right">{{ core()->currency($cart->sub_total) }}</label> <label class="right">{{ core()->currency($cart->base_sub_total) }}</label>
</div> </div>
@if ($cart->selected_shipping_rate) @if ($cart->selected_shipping_rate)
@ -26,6 +26,6 @@
<div class="payble-amount"> <div class="payble-amount">
<label>{{ __('shop::app.checkout.total.grand-total') }}</label> <label>{{ __('shop::app.checkout.total.grand-total') }}</label>
<label class="right">{{ core()->currency($cart->grand_total) }}</label> <label class="right">{{ core()->currency($cart->base_grand_total) }}</label>
</div> </div>
</div> </div>

View File

@ -101,6 +101,8 @@
{!! view_render_event('bagisto.shop.layout.body.after') !!} {!! view_render_event('bagisto.shop.layout.body.after') !!}
<div class="modal-overlay"></div>
</body> </body>
</html> </html>

View File

@ -1,11 +1,11 @@
@extends('shop::layouts.master') @extends('shop::layouts.master')
@section('page_title') @section('page_title')
{{ $product->meta_title ?? $product->name }} {{ trim($product->meta_title) != "" ? $product->meta_title : $product->name }}
@stop @stop
@section('seo') @section('seo')
<meta name="description" content="{{ $product->meta_description }}"/> <meta name="description" content="{{ trim($product->meta_description) != "" ? $product->meta_description : str_limit(strip_tags($product->description), 120, '') }}"/>
<meta name="description" content="{{ $product->meta_keywords }}"/> <meta name="description" content="{{ $product->meta_keywords }}"/>
@stop @stop

View File

@ -9,33 +9,34 @@
{{ __('shop::app.search.no-results') }} {{ __('shop::app.search.no-results') }}
@endif @endif
<div class="main mb-30" style="min-height: 27vh;"> @if($results)
@if($results->isEmpty()) <div class="main mb-30" style="min-height: 27vh;">
<div class="search-result-status"> @if($results->isEmpty())
<h2>{{ __('shop::app.products.whoops') }}</h2> <div class="search-result-status">
<span>{{ __('shop::app.search.no-results') }}</span> <h2>{{ __('shop::app.products.whoops') }}</h2>
</div> <span>{{ __('shop::app.search.no-results') }}</span>
@else
@if($results->count() == 1)
<div class="search-result-status mb-20">
<span><b>{{ $results->count() }} </b>{{ __('shop::app.search.found-result') }}</span>
</div> </div>
@else @else
<div class="search-result-status mb-20"> @if($results->count() == 1)
<span><b>{{ $results->count() }} </b>{{ __('shop::app.search.found-results') }}</span> <div class="search-result-status mb-20">
<span><b>{{ $results->count() }} </b>{{ __('shop::app.search.found-result') }}</span>
</div>
@else
<div class="search-result-status mb-20">
<span><b>{{ $results->count() }} </b>{{ __('shop::app.search.found-results') }}</span>
</div>
@endif
{{-- @include ('shop::products.list.toolbar')
@inject ('toolbarHelper', 'Webkul\Product\Helpers\Toolbar') --}}
<div class="product-grid-4">
@foreach ($results as $product)
@include('shop::products.list.card', ['product' => $product])
@endforeach
</div> </div>
@include('ui::datagrid.pagination')
@endif @endif
{{-- @include ('shop::products.list.toolbar') </div>
@endif
@inject ('toolbarHelper', 'Webkul\Product\Helpers\Toolbar') --}}
<div class="product-grid-4">
@foreach ($results as $product)
@include('shop::products.list.card', ['product' => $product])
@endforeach
</div>
@include('ui::datagrid.pagination')
@endif
</div>
@endsection @endsection

View File

@ -4,6 +4,7 @@ namespace Webkul\Tax\Http\Controllers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\Response; use Illuminate\Http\Response;
use Illuminate\Support\Facades\Event;
use Webkul\Channel as Channel; use Webkul\Channel as Channel;
use Webkul\Tax\Repositories\TaxCategoryRepository as TaxCategory; use Webkul\Tax\Repositories\TaxCategoryRepository as TaxCategory;
use Webkul\Tax\Repositories\TaxRateRepository as TaxRate; use Webkul\Tax\Repositories\TaxRateRepository as TaxRate;
@ -99,28 +100,26 @@ class TaxCategoryController extends Controller
'taxrates' => 'array|required' 'taxrates' => 'array|required'
]); ]);
if($taxCategory = $this->taxCategory->create(request()->input())) { Event::fire('tax.tax_category.create.before');
$allTaxCategories = $data['taxrates'];
//attach the categories in the tax map table $taxCategory = $this->taxCategory->create($data);
$this->taxCategory->attachOrDetach($taxCategory, $allTaxCategories);
session()->flash('success', trans('admin::app.settings.tax-categories.create-success')); //attach the categories in the tax map table
$this->taxCategory->attachOrDetach($taxCategory, $data['taxrates']);
return redirect()->route($this->_config['redirect']); Event::fire('tax.tax_category.create.after', $taxCategory);
} else {
session()->flash('error', trans('admin::app.settings.tax-categories.create-error'));
}
return view($this->_config['view']); session()->flash('success', trans('admin::app.settings.tax-categories.create-success'));
return redirect()->route($this->_config['redirect']);
} }
/** /**
* To show the edit form form the tax category * To show the edit form form the tax category
* *
* @param int $id
* @return view * @return view
*/ */
public function edit($id) public function edit($id)
{ {
$taxCategory = $this->taxCategory->findOrFail($id); $taxCategory = $this->taxCategory->findOrFail($id);
@ -131,10 +130,11 @@ class TaxCategoryController extends Controller
/** /**
* To update the tax category * To update the tax category
* *
* @return view * @param int $id
* @return Response
*/ */
public function update($id)
public function update($id) { {
$this->validate(request(), [ $this->validate(request(), [
'channel_id' => 'required|numeric', 'channel_id' => 'required|numeric',
'code' => 'required|string|unique:tax_categories,code,'.$id, 'code' => 'required|string|unique:tax_categories,code,'.$id,
@ -144,14 +144,19 @@ class TaxCategoryController extends Controller
]); ]);
$data = request()->input(); $data = request()->input();
Event::fire('tax.tax_category.update.before', $id);
$taxCategory = $this->taxCategory->update($data, $id); $taxCategory = $this->taxCategory->update($data, $id);
Event::fire('tax.tax_category.update.after', $taxCategory);
if(!$taxCategory) { if(!$taxCategory) {
session()->flash('error', trans('admin::app.settings.tax-categories.update-error')); session()->flash('error', trans('admin::app.settings.tax-categories.update-error'));
return redirect()->back(); return redirect()->back();
} }
$taxRates = $data['taxrates']; $taxRates = $data['taxrates'];
//attach the categories in the tax map table //attach the categories in the tax map table
@ -170,12 +175,14 @@ class TaxCategoryController extends Controller
*/ */
public function destroy($id) public function destroy($id)
{ {
if($this->taxCategory->count() == 1) { try {
session()->flash('error', trans('admin::app.settings.tax-categories.atleast-one')); Event::fire('tax.tax_category.delete.before', $id);
} else {
$this->taxCategory->delete($id); $this->taxCategory->delete($id);
session()->flash('success', trans('admin::app.settings.tax-categories.delete')); Event::fire('tax.tax_category.delete.after', $id);
} catch(Exception $e) {
return redirect()->back();
} }
return redirect()->back(); return redirect()->back();

View File

@ -4,6 +4,7 @@ namespace Webkul\Tax\Http\Controllers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\Response; use Illuminate\Http\Response;
use Illuminate\Support\Facades\Event;
use Webkul\Tax\Repositories\TaxRateRepository as TaxRate; use Webkul\Tax\Repositories\TaxRateRepository as TaxRate;
@ -91,17 +92,15 @@ class TaxRateController extends Controller
unset($data['zip_code']); unset($data['zip_code']);
} }
if($this->taxRate->create($data)) { Event::fire('tax.tax_rate.create.before');
session()->flash('success', trans('admin::app.settings.tax-rates.create-success'));
return redirect()->route($this->_config['redirect']); $taxRate = $this->taxRate->create($data);
} else {
session()->flash('error', trans('admin::app.settings.tax-rates.create-error'));
return redirect()->back(); Event::fire('tax.tax_rate.create.after', $taxRate);
}
return redirect()->back(); session()->flash('success', trans('admin::app.settings.tax-rates.create-success'));
return redirect()->route($this->_config['redirect']);
} }
/** /**
@ -136,17 +135,15 @@ class TaxRateController extends Controller
'tax_rate' => 'required|numeric' 'tax_rate' => 'required|numeric'
]); ]);
if($this->taxRate->update(request()->input(), $id)) { Event::fire('tax.tax_rate.update.before', $id);
session()->flash('success', trans('admin::app.settings.tax-rates.update-success'));
return redirect()->route($this->_config['redirect']); $taxRate = $this->taxRate->update(request()->input(), $id);
} else {
session()->flash('error', trans('admin::app.settings.tax-rates.update-error'));
return redirect()->back(); Event::fire('tax.tax_rate.update.after', $taxRate);
}
return redirect()->back(); session()->flash('success', trans('admin::app.settings.tax-rates.update-success'));
return redirect()->route($this->_config['redirect']);
} }
/** /**
@ -157,13 +154,18 @@ class TaxRateController extends Controller
*/ */
public function destroy($id) public function destroy($id)
{ {
if($this->taxRate->count() == 1) { // if($this->taxRate->count() == 1) {
session()->flash('error', trans('admin::app.settings.tax-rates.atleast-one')); // session()->flash('error', trans('admin::app.settings.tax-rates.atleast-one'));
} else { // } else {
$this->taxRate->delete($id);
session()->flash('success', trans('admin::app.settings.tax-rates.delete'));
} // session()->flash('success', trans('admin::app.settings.tax-rates.delete'));
// }
Event::fire('tax.tax_rate.delete.before', $id);
$this->taxRate->delete($id);
Event::fire('tax.tax_rate.delete.after', $id);
return redirect()->back(); return redirect()->back();
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
{ {
"/js/ui.js": "/js/ui.js?id=1fdce572fb02cd8c7dad", "/js/ui.js": "/js/ui.js?id=c3ee60fd11e29aca2922",
"/css/ui.css": "/css/ui.css?id=287b4588ed3ee39d4587" "/css/ui.css": "/css/ui.css?id=8d57ae10a97f50169f1f"
} }

View File

@ -567,7 +567,10 @@ class DataGrid
if ($this->aliased) { //aliasing is expected in this case or it will be changed to presence of join bag if ($this->aliased) { //aliasing is expected in this case or it will be changed to presence of join bag
foreach ($parsed as $key=>$value) { foreach ($parsed as $key=>$value) {
if ($key=="sort") { $column_name = $this->findAlias($key);
$column_type = $this->findType($key);
if ($key == "sort") {
//resolve the case with the column helper class //resolve the case with the column helper class
if(substr_count($key,'_') >= 1) if(substr_count($key,'_') >= 1)
$column_name = $this->findAlias($key); $column_name = $this->findAlias($key);
@ -603,18 +606,26 @@ class DataGrid
} }
} else { } else {
foreach ($value as $condition => $filter_value) { foreach ($value as $condition => $filter_value) {
$this->query->where( if($column_type == 'datetime') {
$column_name, $this->query->whereDate(
$this->operators[$condition], $column_name,
$filter_value $this->operators[$condition],
); $filter_value
);
} else {
$this->query->where(
$column_name,
$this->operators[$condition],
$filter_value
);
}
} }
} }
} }
} }
} else { } else {
//this is the case for the non aliasing. //this is the case for the non aliasing.
foreach ($parsed as $key=>$value) { foreach ($parsed as $key => $value) {
if ($key=="sort") { if ($key=="sort") {
@ -631,7 +642,6 @@ class DataGrid
throw new \Exception('Multiple Sort keys Found, Please Resolve the URL Manually.'); throw new \Exception('Multiple Sort keys Found, Please Resolve the URL Manually.');
} }
} elseif ($key=="search") { } elseif ($key=="search") {
$count_keys = count(array_keys($value)); $count_keys = count(array_keys($value));
if($count_keys==1) if($count_keys==1)
$this->query->where(function ($query) use ($parsed) { $this->query->where(function ($query) use ($parsed) {

View File

@ -2,7 +2,7 @@
<label class="image-item" :for="_uid" v-bind:class="{ 'has-image': imageData.length > 0 }"> <label class="image-item" :for="_uid" v-bind:class="{ 'has-image': imageData.length > 0 }">
<input type="hidden" :name="finalInputName"/> <input type="hidden" :name="finalInputName"/>
<input type="file" accept="image/*" :name="finalInputName" ref="imageInput" :id="_uid" @change="addImageView($event)"/> <input type="file" v-validate="'mimes:image/*'" accept="image/*" :name="finalInputName" ref="imageInput" :id="_uid" @change="addImageView($event)"/>
<img class="preview" :src="imageData" v-if="imageData.length > 0"> <img class="preview" :src="imageData" v-if="imageData.length > 0">
@ -53,13 +53,18 @@
var imageInput = this.$refs.imageInput; var imageInput = this.$refs.imageInput;
if (imageInput.files && imageInput.files[0]) { if (imageInput.files && imageInput.files[0]) {
var reader = new FileReader(); if(imageInput.files[0].type.includes('image/')) {
var reader = new FileReader();
reader.onload = (e) => { reader.onload = (e) => {
this.imageData = e.target.result; this.imageData = e.target.result;
}
reader.readAsDataURL(imageInput.files[0]);
} else {
imageInput.value = "";
alert('Only images (.jpeg, .jpg, .png, ..) are allowed.');
} }
reader.readAsDataURL(imageInput.files[0]);
} }
}, },

View File

@ -60,16 +60,22 @@
var this_this = this; var this_this = this;
if(this.multiple) { if(this.multiple) {
this.images.forEach(function(image) { if(this.images.length) {
this_this.items.push(image) this.images.forEach(function(image) {
this_this.items.push(image)
this_this.imageCount++; this_this.imageCount++;
}); });
} else {
this.createFileType();
}
} else { } else {
if(this.images && this.images != '') { if(this.images && this.images != '') {
this.items.push({'id': 'image_' + this.imageCount, 'url': this.images}) this.items.push({'id': 'image_' + this.imageCount, 'url': this.images})
this.imageCount++; this.imageCount++;
} else {
this.createFileType();
} }
} }
}, },

View File

@ -24,6 +24,10 @@ a:active {
color: $brand-color; color: $brand-color;
} }
textarea {
resize: none;
}
ul { ul {
margin: 0; margin: 0;
padding: 0; padding: 0;
@ -709,6 +713,11 @@ h2 {
} }
} }
modal {
display: none;
}
.modal-open { .modal-open {
overflow: hidden; overflow: hidden;
} }

View File

@ -4,6 +4,7 @@ namespace Webkul\User\Http\Controllers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\Response; use Illuminate\Http\Response;
use Illuminate\Support\Facades\Event;
use Webkul\User\Repositories\RoleRepository as Role; use Webkul\User\Repositories\RoleRepository as Role;
/** /**
@ -76,7 +77,11 @@ class RoleController extends Controller
'permission_type' => 'required', 'permission_type' => 'required',
]); ]);
$this->role->create(request()->all()); Event::fire('user.role.create.before');
$role = $this->role->create(request()->all());
Event::fire('user.role.create.after', $role);
session()->flash('success', 'Role created successfully.'); session()->flash('success', 'Role created successfully.');
@ -110,7 +115,11 @@ class RoleController extends Controller
'permission_type' => 'required', 'permission_type' => 'required',
]); ]);
$this->role->update(request()->all(), $id); Event::fire('user.role.update.before', $id);
$role = $this->role->update(request()->all(), $id);
Event::fire('user.role.update.after', $role);
session()->flash('success', 'Role updated successfully.'); session()->flash('success', 'Role updated successfully.');
@ -128,8 +137,12 @@ class RoleController extends Controller
if($this->role->count() == 1) { if($this->role->count() == 1) {
session()->flash('error', 'At least one role is required.'); session()->flash('error', 'At least one role is required.');
} else { } else {
Event::fire('user.role.delete.before', $id);
$this->role->delete($id); $this->role->delete($id);
Event::fire('user.role.delete.after', $id);
session()->flash('success', 'Role source deleted successfully.'); session()->flash('success', 'Role source deleted successfully.');
} }

View File

@ -4,9 +4,11 @@ namespace Webkul\User\Http\Controllers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\Response; use Illuminate\Http\Response;
use Illuminate\Support\Facades\Event;
use Webkul\User\Repositories\AdminRepository as Admin; use Webkul\User\Repositories\AdminRepository as Admin;
use Webkul\User\Repositories\RoleRepository as Role; use Webkul\User\Repositories\RoleRepository as Role;
use Webkul\User\Http\Requests\UserForm; use Webkul\User\Http\Requests\UserForm;
use Hash;
/** /**
* Admin user controller * Admin user controller
@ -92,7 +94,11 @@ class UserController extends Controller
if(isset($data['password']) && $data['password']) if(isset($data['password']) && $data['password'])
$data['password'] = bcrypt($data['password']); $data['password'] = bcrypt($data['password']);
$this->admin->create($data); Event::fire('user.admin.create.before');
$admin = $this->admin->create($data);
Event::fire('user.admin.delete.after', $admin);
session()->flash('success', 'User created successfully.'); session()->flash('success', 'User created successfully.');
@ -136,7 +142,11 @@ class UserController extends Controller
$data['status'] = 0; $data['status'] = 0;
} }
$this->admin->update($data, $id); Event::fire('user.admin.update.before', $id);
$admin = $this->admin->update($data, $id);
Event::fire('user.admin.update.after', $admin);
session()->flash('success', 'User updated successfully.'); session()->flash('success', 'User updated successfully.');
@ -154,11 +164,51 @@ class UserController extends Controller
if($this->admin->count() == 1) { if($this->admin->count() == 1) {
session()->flash('error', 'At least one admin is required.'); session()->flash('error', 'At least one admin is required.');
} else { } else {
Event::fire('user.admin.delete.before', $id);
if (auth()->guard('admin')->user()->id == $id) {
return view('admin::customers.confirm-password');
}
$this->admin->delete($id); $this->admin->delete($id);
Event::fire('user.admin.delete.after', $id);
session()->flash('success', 'Admin source deleted successfully.'); session()->flash('success', 'Admin source deleted successfully.');
} }
return redirect()->back(); return redirect()->back();
} }
/**
* destroy current after confirming
*
* @return mixed
*/
public function destroySelf()
{
$password = request()->input('password');
if(Hash::check($password, auth()->guard('admin')->user()->password)) {
if($this->admin->count() == 1) {
session()->flash('error', trans('admin::app.users.users.delete-last'));
} else {
$id = auth()->guard('admin')->user()->id;
Event::fire('user.admin.delete.before', $id);
$this->admin->delete($id);
Event::fire('user.admin.delete.after', $id);
session()->flash('success', trans('admin::app.users.users.delete-success'));
return redirect()->route('admin.session.create');
}
} else {
session()->flash('warning', trans('admin::app.users.users.incorrect-password'));
return redirect()->route($this->_config['redirect']);
}
}
} }

View File

@ -29,10 +29,10 @@ class Bouncer
public function checkIfAuthorized($request) public function checkIfAuthorized($request)
{ {
if(!$role = auth()->guard('admin')->user()->role) if (!$role = auth()->guard('admin')->user()->role)
abort(401, 'This action is unauthorized.'); abort(401, 'This action is unauthorized.');
if($role->permission_type == 'all'){ if ($role->permission_type == 'all') {
return; return;
} else { } else {
$acl = app('acl'); $acl = app('acl');