Merge pull request #1 from bagisto/master

merge with master
This commit is contained in:
rahulshukla-webkul 2018-12-26 14:52:34 +05:30 committed by GitHub
commit 4c2df325e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
52 changed files with 628 additions and 277 deletions

View File

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

View File

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

View File

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

View File

@ -324,6 +324,10 @@ Route::group(['middleware' => ['web']], function () {
//delete backend user
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
Route::get('/roles', 'Webkul\User\Http\Controllers\RoleController@index')->defaults('_config', [
'view' => 'admin::users.roles.index'

View File

@ -67,7 +67,7 @@ class Order {
$productListener = app(\Webkul\Admin\Listeners\Product::class);
foreach ($order->items as $item) {
$productListener->afterProductCreated($item->product);
$productListener->afterOrderRecieved($item->product->id, $item->qty_ordered);
}
}
}

View File

@ -73,6 +73,10 @@ class Product {
$variants = [];
$found = $this->productGrid->findOneByField('product_id', $product->id);
//extra measure to stop duplicate entries
if($found == null) {
$this->productGrid->create($gridObject);
if($product->type == 'configurable') {
@ -93,6 +97,7 @@ class Product {
$this->productGrid->create($variantObj);
}
}
}
return true;
}
@ -213,6 +218,20 @@ class Product {
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.
*/
@ -254,6 +273,13 @@ class Product {
$gridObject = [];
}
$this->findRepeated();
return true;
}
public function findRepeated() {
}
}

View File

@ -21,5 +21,13 @@ class EventServiceProvider extends ServiceProvider
Event::listen('checkout.invoice.save.after', 'Webkul\Admin\Listeners\Order@sendNewShipmentMail');
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',
'current-password' => 'Current Password'
],
'users' => [
'forget-password' => [
'title' => 'Forget Password',
@ -60,6 +61,7 @@ return [
'back-link-title' => 'Back to Sign In',
'submit-btn-title' => 'Email Password Reset Link'
],
'reset-password' => [
'title' => 'Reset Password',
'title' => 'Reset Password',
@ -69,6 +71,7 @@ return [
'back-link-title' => 'Back to Sign In',
'submit-btn-title' => 'Reset Password'
],
'roles' => [
'title' => 'Roles',
'add-role-title' => 'Add Role',
@ -82,6 +85,7 @@ return [
'custom' => 'Custom',
'all' => 'All'
],
'users' => [
'title' => 'User',
'add-user-title' => 'Add User',
@ -95,8 +99,15 @@ return [
'status-and-role' => 'Status and Role',
'role' => 'Role',
'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' => [
'title' => 'Sign In',
'email' => 'Email',
@ -106,6 +117,7 @@ return [
'submit-btn-title' => 'Sign In'
]
],
'sales' => [
'orders' => [
'title' => 'Orders',
@ -157,6 +169,7 @@ return [
'total-due' => 'Total Due',
'cancel-confirm-msg' => 'Are you sure you want to cancel this order ?'
],
'invoices' => [
'title' => 'Invoices',
'id' => 'Id',
@ -178,6 +191,7 @@ return [
'print' => 'Print',
'order-date' => 'Order Date'
],
'shipments' => [
'title' => 'Shipments',
'id' => 'Id',
@ -196,6 +210,7 @@ return [
'view-title' => 'Shipment #:shipment_id',
]
],
'catalog' => [
'products' => [
'title' => 'Products',
@ -227,8 +242,10 @@ return [
'add-variant-title' => 'Add Variant',
'variant-already-exist-message' => 'Variant with same attribute options already exists.',
'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' => [
'title' => 'Attributes',
'add-title' => 'Add Attribute',

View File

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

View File

@ -92,7 +92,7 @@
{{ $attribute->admin_name }}
@if ($attribute->type == 'price')
<span class="currency-code">({{ currency()->symbol(core()->getBaseCurrencyCode()) }})</span>
<span class="currency-code">({{ core()->currencySymbol(core()->getBaseCurrencyCode()) }})</span>
@endif
<?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">
<label>Account</label>
<ul>
<li>
<a href="{{ route('shop.home.index') }}" target="_blank">Visit Shop</a>
</li>
<li>
<a href="{{ route('admin.account.edit') }}">My Account</a>
</li>

View File

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

View File

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

View File

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

View File

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

View File

@ -639,9 +639,16 @@ class Cart {
}
}
$cart->customer_email = $cart->shipping_address->email;
$cart->customer_first_name = $cart->shipping_address->first_name;
$cart->customer_last_name = $cart->shipping_address->last_name;
if(auth()->guard('customer')->check()) {
$cart->customer_email = auth()->guard('customer')->user()->email;
$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();
return true;

View File

@ -339,7 +339,7 @@ class Core
if (null === $exchangeRate)
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 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
*

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\Response;
use Illuminate\Support\Facades\Event;
use Webkul\Core\Repositories\ChannelRepository as Channel;
@ -77,10 +78,16 @@ class ChannelController extends Controller
'locales' => 'required|array|min:1',
'default_locale_id' => 'required',
'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.');
@ -115,10 +122,16 @@ class ChannelController extends Controller
'locales' => 'required|array|min:1',
'default_locale_id' => 'required',
'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.');
@ -136,8 +149,12 @@ class ChannelController extends Controller
if($this->channel->count() == 1) {
session()->flash('error', 'At least one channel is required.');
} else {
Event::fire('core.channel.delete.before', $id);
$this->channel->delete($id);
Event::fire('core.channel.delete.after', $id);
session()->flash('success', 'Channel deleted successfully.');
}

View File

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

View File

@ -4,6 +4,7 @@ namespace Webkul\Core\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Event;
use Webkul\Core\Repositories\CurrencyRepository as Currency;
/**
@ -76,7 +77,11 @@ class CurrencyController extends Controller
'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.');
@ -110,7 +115,11 @@ class CurrencyController extends Controller
'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.');
@ -125,12 +134,20 @@ class CurrencyController extends Controller
*/
public function destroy($id)
{
try {
Event::fire('core.currency.delete.before', $id);
$result = $this->currency->delete($id);
Event::fire('core.currency.delete.after', $id);
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();
}
@ -148,7 +165,11 @@ class CurrencyController extends Controller
foreach($indexes as $key => $value) {
try {
Event::fire('core.currency.delete.before', $value);
$this->currency->delete($value);
Event::fire('core.currency.delete.after', $value);
} catch(\Exception $e) {
$suppressFlash = true;

View File

@ -4,6 +4,7 @@ namespace Webkul\Core\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Event;
use Webkul\Core\Repositories\ExchangeRateRepository as ExchangeRate;
use Webkul\Core\Repositories\CurrencyRepository as Currency;
@ -89,7 +90,11 @@ class ExchangeRateController extends Controller
'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.');
@ -125,7 +130,11 @@ class ExchangeRateController extends Controller
'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.');
@ -143,8 +152,12 @@ class ExchangeRateController extends Controller
if($this->exchangeRate->count() == 1) {
session()->flash('error', 'At least one Exchange rate is required.');
} else {
Event::fire('core.exchange_rate.delete.before', $id);
$this->exchangeRate->delete($id);
Event::fire('core.exchange_rate.delete.after', $id);
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\Response;
use Illuminate\Support\Facades\Event;
use Webkul\Core\Repositories\LocaleRepository as Locale;
/**
@ -76,7 +77,11 @@ class LocaleController extends Controller
'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.');
@ -110,7 +115,11 @@ class LocaleController extends Controller
'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.');
@ -128,8 +137,12 @@ class LocaleController extends Controller
if($this->locale->count() == 1) {
session()->flash('error', 'At least one locale is required.');
} else {
Event::fire('core.locale.delete.before', $id);
$this->locale->delete($id);
Event::fire('core.locale.delete.after', $id);
session()->flash('success', 'Locale deleted successfully.');
}

View File

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

View File

@ -10,7 +10,6 @@ use Webkul\Core\Eloquent\Repository;
* @author Prashant Singh <prashant.singh852@webkul.com>
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class CustomerRepository extends Repository
{
/**
@ -23,32 +22,4 @@ class CustomerRepository extends Repository
{
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\Response;
use Illuminate\Support\Facades\Event;
use Webkul\Inventory\Repositories\InventorySourceRepository as InventorySource;
/**
@ -85,7 +86,11 @@ class InventorySourceController extends Controller
$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.');
@ -131,7 +136,11 @@ class InventorySourceController extends Controller
$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.');
@ -149,8 +158,12 @@ class InventorySourceController extends Controller
if($this->inventorySource->count() == 1) {
session()->flash('error', 'At least one inventory source is required.');
} else {
Event::fire('inventory.inventory_source.delete.before', $id);
$this->inventorySource->delete($id);
Event::fire('inventory.inventory_source.delete.after', $id);
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\Response;
use Illuminate\Support\Facades\Event;
use Webkul\Product\Http\Requests\ProductForm;
use Webkul\Product\Repositories\ProductRepository as Product;
use Webkul\Product\Repositories\ProductGridRepository as ProductGrid;
use Webkul\Attribute\Repositories\AttributeFamilyRepository as AttributeFamily;
use Webkul\Category\Repositories\CategoryRepository as Category;
use Webkul\Inventory\Repositories\InventorySourceRepository as InventorySource;
use Event;
/**
* Product controller
@ -126,9 +126,6 @@ class ProductController extends Controller
*/
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') != '') {
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]
]);
//before store of the product
Event::fire('catalog.product.create.before');
$product = $this->product->create(request()->all());
//after store of the product
Event::fire('product.save.after', $product);
Event::fire('catalog.product.create.after', $product);
session()->flash('success', 'Product created successfully.');
@ -181,13 +181,11 @@ class ProductController extends Controller
*/
public function update(ProductForm $request, $id)
{
// before update of product
// Event::fire('product.update.before', $id);
Event::fire('catalog.product.update.before', $id);
$product = $this->product->update(request()->all(), $id);
//after update of product
Event::fire('product.update.after', $product);
Event::fire('catalog.product.update.after', $product);
session()->flash('success', 'Product updated successfully.');
@ -202,12 +200,11 @@ class ProductController extends Controller
*/
public function destroy($id)
{
Event::fire('product.delete.before', $id);
Event::fire('catalog.product.delete.before', $id);
$this->product->delete($id);
//before update of product
// Event::fire('product.delete.after', $id);
Event::fire('catalog.product.delete.after', $id);
session()->flash('success', 'Product deleted successfully.');
@ -228,7 +225,11 @@ class ProductController extends Controller
$product = $this->product->find($productId);
if(!is_null($product)) {
Event::fire('catalog.product.delete.before', $productId);
$product->delete();
Event::fire('catalog.product.delete.after', $productId);
}
}
}
@ -258,11 +259,15 @@ class ProductController extends Controller
$product = $this->product->find($productId);
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']);
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') {
Event::fire('catelog.product.update.before', $productId);
$result = $this->product->updateAttribute($product, $attribute, $data['update-options']);
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']);
}

View File

@ -4,6 +4,7 @@ namespace Webkul\Product\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Event;
use Webkul\Product\Repositories\ProductRepository as Product;
use Webkul\Product\Repositories\ProductReviewRepository as ProductReview;
@ -85,8 +86,12 @@ class ReviewController extends Controller
*/
public function update(Request $request, $id)
{
Event::fire('customer.review.update.before', $id);
$this->productReview->update(request()->all(), $id);
Event::fire('customer.review.update.after', $id);
session()->flash('success', 'Review updated successfully.');
return redirect()->route($this->_config['redirect']);
@ -100,8 +105,12 @@ class ReviewController extends Controller
*/
public function destroy($id)
{
Event::fire('customer.review.delete.before', $id);
$this->productReview->delete($id);
Event::fire('customer.review.delete.after', $id);
session()->flash('success', 'Review Successfully Deleted');
return redirect()->back();
@ -122,7 +131,11 @@ class ReviewController extends Controller
foreach($indexes as $key => $value) {
try {
Event::fire('customer.review.delete.before', $value);
$this->productReview->delete($value);
Event::fire('customer.review.delete.after', $value);
} catch(\Exception $e) {
$suppressFlash = true;
@ -162,7 +175,11 @@ class ReviewController extends Controller
try {
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']);
Event::fire('customer.review.update.after', $review);
} else if($data['massaction-type'] == 1 && $data['update-options'] == 0 && $data['selected-option-text'] == 'Disapprove') {
$review->update(['status' => 'pending']);
} 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\Routing\Router;
use Webkul\Product\Models\Product;
use Webkul\Product\Observers\ProductObserver;
use Event;
class ProductServiceProvider extends ServiceProvider
{
@ -18,20 +16,6 @@ class ProductServiceProvider extends ServiceProvider
public function boot(Router $router)
{
$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;
if (str_contains($imageId, 'image_')) {
if(request()->hasFile($file)) {
$this->create([
'path' => request()->file($file)->store($dir),
'product_id' => $product->id
]);
}
} else {
if(is_numeric($index = $previousImageIds->search($imageId))) {
$previousImageIds->forget($index);

View File

@ -26,7 +26,13 @@ return [
'name' => 'Wishlist',
'route' =>'customer.wishlist.index',
'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(), [
'title' => 'string|required',
'channel_id' => 'required',
'image' => 'required',
'image' => 'required|mimes:jpeg,bmp,png'
]);
$result = $this->slider->save(request()->all());
@ -90,6 +90,7 @@ class SliderController extends controller
$this->validate(request(), [
'title' => 'string|required',
'channel_id' => 'required',
'image' => 'sometimes|mimes:jpeg,bmp,png'
]);
$result = $this->slider->updateItem(request()->all(), $id);

View File

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

View File

@ -25,6 +25,10 @@ body {
font-family: "Montserrat", sans-serif;
}
textarea {
resize: none;
}
input {
font-family: 'Montserrat', sans-serif;
}
@ -452,7 +456,11 @@ input {
}
.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) {

View File

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

View File

@ -22,7 +22,7 @@
<div class="dropdown-header">
<p class="heading">
{{ __('shop::app.checkout.cart.cart-subtotal') }} -
{{ core()->currency($cart->sub_total) }}
{{ core()->currency($cart->base_sub_total) }}
</p>
</div>
@ -53,7 +53,7 @@
</div>
@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>

View File

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

View File

@ -1,11 +1,11 @@
@extends('shop::layouts.master')
@section('page_title')
{{ $product->meta_title ?? $product->name }}
{{ trim($product->meta_title) != "" ? $product->meta_title : $product->name }}
@stop
@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 }}"/>
@stop

View File

@ -9,6 +9,7 @@
{{ __('shop::app.search.no-results') }}
@endif
@if($results)
<div class="main mb-30" style="min-height: 27vh;">
@if($results->isEmpty())
<div class="search-result-status">
@ -37,5 +38,5 @@
@include('ui::datagrid.pagination')
@endif
</div>
@endif
@endsection

View File

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

View File

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

View File

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

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=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
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
if(substr_count($key,'_') >= 1)
$column_name = $this->findAlias($key);
@ -603,6 +606,13 @@ class DataGrid
}
} else {
foreach ($value as $condition => $filter_value) {
if($column_type == 'datetime') {
$this->query->whereDate(
$column_name,
$this->operators[$condition],
$filter_value
);
} else {
$this->query->where(
$column_name,
$this->operators[$condition],
@ -612,9 +622,10 @@ class DataGrid
}
}
}
}
} else {
//this is the case for the non aliasing.
foreach ($parsed as $key=>$value) {
foreach ($parsed as $key => $value) {
if ($key=="sort") {
@ -631,7 +642,6 @@ class DataGrid
throw new \Exception('Multiple Sort keys Found, Please Resolve the URL Manually.');
}
} elseif ($key=="search") {
$count_keys = count(array_keys($value));
if($count_keys==1)
$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 }">
<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">
@ -53,6 +53,7 @@
var imageInput = this.$refs.imageInput;
if (imageInput.files && imageInput.files[0]) {
if(imageInput.files[0].type.includes('image/')) {
var reader = new FileReader();
reader.onload = (e) => {
@ -60,6 +61,10 @@
}
reader.readAsDataURL(imageInput.files[0]);
} else {
imageInput.value = "";
alert('Only images (.jpeg, .jpg, .png, ..) are allowed.');
}
}
},

View File

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

View File

@ -24,6 +24,10 @@ a:active {
color: $brand-color;
}
textarea {
resize: none;
}
ul {
margin: 0;
padding: 0;

View File

@ -4,6 +4,7 @@ namespace Webkul\User\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Event;
use Webkul\User\Repositories\RoleRepository as Role;
/**
@ -76,7 +77,11 @@ class RoleController extends Controller
'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.');
@ -110,7 +115,11 @@ class RoleController extends Controller
'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.');
@ -128,8 +137,12 @@ class RoleController extends Controller
if($this->role->count() == 1) {
session()->flash('error', 'At least one role is required.');
} else {
Event::fire('user.role.delete.before', $id);
$this->role->delete($id);
Event::fire('user.role.delete.after', $id);
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\Response;
use Illuminate\Support\Facades\Event;
use Webkul\User\Repositories\AdminRepository as Admin;
use Webkul\User\Repositories\RoleRepository as Role;
use Webkul\User\Http\Requests\UserForm;
use Hash;
/**
* Admin user controller
@ -92,7 +94,11 @@ class UserController extends Controller
if(isset($data['password']) && $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.');
@ -136,7 +142,11 @@ class UserController extends Controller
$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.');
@ -154,11 +164,51 @@ class UserController extends Controller
if($this->admin->count() == 1) {
session()->flash('error', 'At least one admin is required.');
} 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);
Event::fire('user.admin.delete.after', $id);
session()->flash('success', 'Admin source deleted successfully.');
}
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']);
}
}
}