Optimized and refactored code

This commit is contained in:
jitendra 2022-08-06 20:41:23 +05:30
parent b41368a410
commit 809a215730
57 changed files with 347 additions and 459 deletions

13
config/.gitignore vendored Normal file
View File

@ -0,0 +1,13 @@
db-blade-compiler.php
debugbar.php
dompdf.php
excel.php
flare.php
ignition.php
image.php
imagecache.php
jwt.php
repository.php
scout.php
tinker.php
translatable.php

View File

@ -79,6 +79,7 @@ class ConfigurationController extends Controller
{
if (! request()->route('slug')) {
$firstItem = current($this->configTree->items);
$secondItem = current($firstItem['children']);
return $this->getSlugs($secondItem);
@ -109,6 +110,7 @@ class ConfigurationController extends Controller
foreach ($data['sales']['carriers'] as $carrier) {
if ($carrier['active']) {
$atLeastOneCarrierEnabled = true;
break;
}
}

View File

@ -73,8 +73,6 @@ class AddressController extends Controller
'address1' => implode(PHP_EOL, array_filter(request()->input('address1'))),
]);
$data = collect(request()->input())->except('_token')->toArray();
$this->validate(request(), [
'company_name' => 'string',
'address1' => 'string|required',
@ -86,10 +84,10 @@ class AddressController extends Controller
'vat_id' => new VatIdRule(),
]);
if ($this->customerAddressRepository->create($data)) {
if ($this->customerAddressRepository->create(request()->all())) {
session()->flash('success', trans('admin::app.customers.addresses.success-create'));
return redirect()->route('admin.customer.edit', ['id' => $data['customer_id']]);
return redirect()->route('admin.customer.edit', ['id' => request('customer_id')]);
} else {
session()->flash('success', trans('admin::app.customers.addresses.error-create'));
@ -131,18 +129,11 @@ class AddressController extends Controller
'vat_id' => new VatIdRule(),
]);
$data = collect(request()->input())->except('_token')->toArray();
$this->customerAddressRepository->update(request()->all(), $id);
$address = $this->customerAddressRepository->find($id);
session()->flash('success', trans('admin::app.customers.addresses.success-update'));
if ($address) {
$this->customerAddressRepository->update($data, $id);
session()->flash('success', trans('admin::app.customers.addresses.success-update'));
return redirect()->route('admin.customer.addresses.index', ['id' => $address->customer_id]);
}
return redirect()->route($this->_config['redirect']);
return redirect()->route('admin.customer.addresses.index', ['id' => $address->customer_id]);
}
/**
@ -157,7 +148,7 @@ class AddressController extends Controller
return response()->json([
'redirect' => false,
'message' => trans('admin::app.customers.addresses.success-delete')
'message' => trans('admin::app.customers.addresses.success-delete')
]);
}

View File

@ -8,8 +8,6 @@ use Webkul\Admin\DataGrids\CustomerOrderDataGrid;
use Webkul\Admin\DataGrids\CustomersInvoicesDataGrid;
use Webkul\Admin\Http\Controllers\Controller;
use Webkul\Admin\Mail\NewCustomerNotification;
use Webkul\Core\Repositories\ChannelRepository;
use Webkul\Customer\Repositories\CustomerAddressRepository;
use Webkul\Customer\Repositories\CustomerGroupRepository;
use Webkul\Customer\Repositories\CustomerRepository;
@ -26,15 +24,11 @@ class CustomerController extends Controller
* Create a new controller instance.
*
* @param \Webkul\Customer\Repositories\CustomerRepository $customerRepository
* @param \Webkul\Customer\Repositories\CustomerAddressRepository $customerAddressRepository
* @param \Webkul\Customer\Repositories\CustomerGroupRepository $customerGroupRepository
* @param \Webkul\Core\Repositories\ChannelRepository $channelRepository
*/
public function __construct(
protected CustomerRepository $customerRepository,
protected CustomerAddressRepository $customerAddressRepository,
protected CustomerGroupRepository $customerGroupRepository,
protected ChannelRepository $channelRepository
protected CustomerGroupRepository $customerGroupRepository
)
{
$this->_config = request('_config');
@ -61,11 +55,9 @@ class CustomerController extends Controller
*/
public function create()
{
$customerGroup = $this->customerGroupRepository->findWhere([['code', '<>', 'guest']]);
$groups = $this->customerGroupRepository->findWhere([['code', '<>', 'guest']]);
$channelName = $this->channelRepository->all();
return view($this->_config['view'], compact('customerGroup', 'channelName'));
return view($this->_config['view'], compact('groups'));
}
/**
@ -83,18 +75,16 @@ class CustomerController extends Controller
'date_of_birth' => 'date|before:today',
]);
$data = request()->all();
$password = rand(100000, 10000000);
$data['password'] = bcrypt($password);
$data['is_verified'] = 1;
$customer = $this->customerRepository->create($data);
$customer = $this->customerRepository->create(array_merge(request()->all() , [
'password' => bcrypt($password),
'is_verified' => 1,
]));
try {
$configKey = 'emails.general.notifications.emails.general.notifications.customer';
if (core()->getConfigData($configKey)) {
Mail::queue(new NewCustomerNotification($customer, $password));
}
@ -116,11 +106,10 @@ class CustomerController extends Controller
public function edit($id)
{
$customer = $this->customerRepository->findOrFail($id);
$address = $this->customerAddressRepository->find($id);
$customerGroup = $this->customerGroupRepository->findWhere([['code', '<>', 'guest']]);
$channelName = $this->channelRepository->all();
return view($this->_config['view'], compact('customer', 'address', 'customerGroup', 'channelName'));
$groups = $this->customerGroupRepository->findWhere([['code', '<>', 'guest']]);
return view($this->_config['view'], compact('customer', 'groups'));
}
/**
@ -139,13 +128,10 @@ class CustomerController extends Controller
'date_of_birth' => 'date|before:today',
]);
$data = request()->all();
$data['status'] = ! isset($data['status']) ? 0 : 1;
$data['is_suspended'] = ! isset($data['is_suspended']) ? 0 : 1;
$this->customerRepository->update($data, $id);
$this->customerRepository->update(array_merge(request()->all(), [
'status' => isset($data['status']),
'is_suspended' => isset($data['is_suspended']),
]), $id);
session()->flash('success', trans('admin::app.response.update-success', ['name' => 'Customer']));
@ -203,11 +189,7 @@ class CustomerController extends Controller
$noteTaken = $customer->update(['notes' => request()->input('notes')]);
if ($noteTaken) {
session()->flash('success', 'Note taken');
} else {
session()->flash('error', 'Note cannot be taken');
}
session()->flash('success', 'Note taken');
return redirect()->route($this->_config['redirect']);
}
@ -220,6 +202,7 @@ class CustomerController extends Controller
public function massUpdate()
{
$customerIds = explode(',', request()->input('indexes'));
$updateOption = request()->input('update-options');
foreach ($customerIds as $customerId) {
@ -254,6 +237,7 @@ class CustomerController extends Controller
}
session()->flash('error', trans('admin::app.response.order-pending', ['name' => 'Customers']));
return redirect()->back();
}

View File

@ -62,11 +62,9 @@ class CustomerGroupController extends Controller
'name' => 'required',
]);
$data = request()->all();
$data['is_user_defined'] = 1;
$this->customerGroupRepository->create($data);
$this->customerGroupRepository->create(array_merge(request()->all() , [
'is_user_defined' => 1,
]));
session()->flash('success', trans('admin::app.response.create-success', ['name' => 'Customer Group']));
@ -116,13 +114,13 @@ class CustomerGroupController extends Controller
{
$customerGroup = $this->customerGroupRepository->findOrFail($id);
if ($customerGroup->is_user_defined == 0) {
if (! $customerGroup->is_user_defined) {
return response()->json([
'message' => trans('admin::app.customers.customers.group-default'),
], 400);
}
if (count($customerGroup->customers) > 0) {
if ($customerGroup->customers->count()) {
return response()->json([
'message' => trans('admin::app.response.customer-associate', ['name' => 'Customer Group']),
], 400);

View File

@ -20,9 +20,7 @@ class ExportController extends Controller
$gridName = explode('\\', $criteria['gridName']);
$path = '\Webkul\Admin\DataGrids' . '\\' . last($gridName);
$gridInstance = app($path);
$gridInstance = app('\Webkul\Admin\DataGrids' . '\\' . last($gridName));
$records = $gridInstance->export();
@ -34,9 +32,7 @@ class ExportController extends Controller
if ($format == 'csv') {
return Excel::download(new DataGridExport($records), last($gridName) . '.csv');
}
if ($format == 'xls') {
} elseif ($format == 'xls') {
return Excel::download(new DataGridExport($records), last($gridName) . '.xlsx');
}

View File

@ -99,21 +99,21 @@ class InvoiceController extends Controller
'invoice.items.*' => 'required|numeric|min:0',
]);
$data = request()->all();
if (! $this->invoiceRepository->haveProductToInvoice($data)) {
if (! $this->invoiceRepository->haveProductToInvoice(request()->all())) {
session()->flash('error', trans('admin::app.sales.invoices.product-error'));
return redirect()->back();
}
if (! $this->invoiceRepository->isValidQuantity($data)) {
if (! $this->invoiceRepository->isValidQuantity(request()->all())) {
session()->flash('error', trans('admin::app.sales.invoices.invalid-qty'));
return redirect()->back();
}
$this->invoiceRepository->create(array_merge($data, ['order_id' => $orderId]));
$this->invoiceRepository->create(array_merge(request()->all(), [
'order_id' => $orderId,
]));
session()->flash('success', trans('admin::app.response.create-success', ['name' => 'Invoice']));
@ -148,15 +148,9 @@ class InvoiceController extends Controller
$invoice = $this->invoiceRepository->findOrFail($id);
if ($invoice) {
$this->sendDuplicateInvoiceMail($invoice, $request->email);
$this->sendDuplicateInvoiceMail($invoice, $request->email);
session()->flash('success', __('admin::app.sales.invoices.invoice-sent'));
return redirect()->back();
}
session()->flash('error', __('admin::app.response.something-went-wrong'));
session()->flash('success', trans('admin::app.sales.invoices.invoice-sent'));
return redirect()->back();
}

View File

@ -86,15 +86,12 @@ class OrderController extends Controller
*/
public function comment($id)
{
$data = array_merge(request()->all(), [
'order_id' => $id,
]);
Event::dispatch('sales.order.comment.create.before');
$data['customer_notified'] = isset($data['customer_notified']) ? 1 : 0;
Event::dispatch('sales.order.comment.create.before', $data);
$comment = $this->orderCommentRepository->create($data);
$comment = $this->orderCommentRepository->create(array_merge(request()->all(), [
'order_id' => $id,
'customer_notified' => isset($data['customer_notified']),
]));
Event::dispatch('sales.order.comment.create.after', $comment);

View File

@ -88,15 +88,15 @@ class ShipmentController extends Controller
'shipment.items.*.*' => 'required|numeric|min:0',
]);
$data = request()->all();
if (! $this->isInventoryValidate($data)) {
if (! $this->isInventoryValidate(request()->all())) {
session()->flash('error', trans('admin::app.sales.shipments.quantity-invalid'));
return redirect()->back();
}
$this->shipmentRepository->create(array_merge($data, ['order_id' => $orderId]));
$this->shipmentRepository->create(array_merge(request()->all(), [
'order_id' => $orderId,
]));
session()->flash('success', trans('admin::app.response.create-success', ['name' => 'Shipment']));
@ -141,7 +141,10 @@ class ShipmentController extends Controller
->where('inventory_source_id', $inventorySourceId)
->sum('qty');
if ($child->qty_to_ship < $finalQty || $availableQty < $finalQty) {
if (
$child->qty_to_ship < $finalQty
|| $availableQty < $finalQty
) {
return false;
}
}
@ -150,7 +153,10 @@ class ShipmentController extends Controller
->where('inventory_source_id', $inventorySourceId)
->sum('qty');
if ($orderItem->qty_to_ship < $qty || $availableQty < $qty) {
if (
$orderItem->qty_to_ship < $qty
|| $availableQty < $qty
) {
return false;
}
}

View File

@ -5,6 +5,8 @@ namespace Webkul\Admin\Listeners;
use Illuminate\Support\Facades\Mail;
use Webkul\User\Notifications\AdminUpdatePassword;
use Webkul\Customer\Notifications\CustomerUpdatePassword;
use Webkul\Customer\Models\Customer;
use Webkul\User\Models\Admin;
class PasswordChange
{
@ -17,11 +19,9 @@ class PasswordChange
public function sendUpdatePasswordMail($adminOrCustomer)
{
try {
if ($adminOrCustomer instanceof \Webkul\Customer\Models\Customer) {
if ($adminOrCustomer instanceof Customer) {
Mail::queue(new CustomerUpdatePassword($adminOrCustomer));
}
if ($adminOrCustomer instanceof \Webkul\User\Models\Admin) {
} elseif ($adminOrCustomer instanceof Admin) {
Mail::queue(new AdminUpdatePassword($adminOrCustomer));
}
} catch (\Exception $e) {

View File

@ -21,8 +21,8 @@ class CancelOrderAdminNotification extends Mailable
public function build()
{
return $this->from(core()->getSenderEmailDetails()['email'], core()->getSenderEmailDetails()['name'])
->to(core()->getAdminEmailDetails()['email'])
->subject(trans('shop::app.mail.order.cancel.subject'))
->view('shop::emails.sales.order-cancel-admin');
->to(core()->getAdminEmailDetails()['email'])
->subject(trans('shop::app.mail.order.cancel.subject'))
->view('shop::emails.sales.order-cancel-admin');
}
}

View File

@ -22,8 +22,8 @@ class CancelOrderNotification extends Mailable
public function build()
{
return $this->from(core()->getSenderEmailDetails()['email'], core()->getSenderEmailDetails()['name'])
->to($this->order->customer_email, $this->order->customer_full_name)
->subject(trans('shop::app.mail.order.cancel.subject'))
->view('shop::emails.sales.order-cancel');
->to($this->order->customer_email, $this->order->customer_full_name)
->subject(trans('shop::app.mail.order.cancel.subject'))
->view('shop::emails.sales.order-cancel');
}
}

View File

@ -21,7 +21,8 @@ class DuplicateInvoiceNotification extends Mailable
public $invoice,
public $customerEmail
)
{}
{
}
/**
* Build the message.

View File

@ -16,12 +16,15 @@ class InvoiceOverdueReminder extends Mailable
*
* @param \Webkul\Customer\Contracts\Customer $customer
* @param \Webkul\Sales\Contracts\Invoice $invoice
* @return void
*/
public function __construct(
public $customer,
public $invoice
)
{}
{
}
/**
* Build the message.
@ -31,8 +34,11 @@ class InvoiceOverdueReminder extends Mailable
public function build()
{
return $this->from(core()->getSenderEmailDetails()['email'], core()->getSenderEmailDetails()['name'])
->to($this->customer->email)
->subject(trans('shop::app.mail.invoice.reminder.subject'))
->view('shop::emails.customer.invoice-reminder')->with(['customer' => $this->customer, 'invoice' => $this->invoice]);
->to($this->customer->email)
->subject(trans('shop::app.mail.invoice.reminder.subject'))
->view('shop::emails.customer.invoice-reminder')->with([
'customer' => $this->customer,
'invoice' => $this->invoice,
]);
}
}

View File

@ -29,8 +29,8 @@ class NewAdminNotification extends Mailable
public function build()
{
return $this->from(core()->getSenderEmailDetails()['email'], core()->getSenderEmailDetails()['name'])
->to(core()->getAdminEmailDetails()['email'])
->subject(trans('shop::app.mail.order.subject'))
->view('shop::emails.sales.new-admin-order');
->to(core()->getAdminEmailDetails()['email'])
->subject(trans('shop::app.mail.order.subject'))
->view('shop::emails.sales.new-admin-order');
}
}

View File

@ -33,8 +33,11 @@ class NewCustomerNotification extends Mailable
public function build()
{
return $this->from(core()->getSenderEmailDetails()['email'], core()->getSenderEmailDetails()['name'])
->to($this->customer->email)
->subject(trans('shop::app.mail.customer.new.subject'))
->view('shop::emails.customer.new-customer')->with(['customer' => $this->customer, 'password' => $this->password]);
->to($this->customer->email)
->subject(trans('shop::app.mail.customer.new.subject'))
->view('shop::emails.customer.new-customer')->with([
'customer' => $this->customer,
'password' => $this->password,
]);
}
}

View File

@ -33,8 +33,8 @@ class NewInventorySourceNotification extends Mailable
$inventory = $this->shipment->inventory_source;
return $this->from(core()->getSenderEmailDetails()['email'], core()->getSenderEmailDetails()['name'])
->to($inventory->contact_email, $inventory->name)
->subject(trans('shop::app.mail.shipment.subject', ['order_id' => $order->increment_id]))
->view('shop::emails.sales.new-inventorysource-shipment');
->to($inventory->contact_email, $inventory->name)
->subject(trans('shop::app.mail.shipment.subject', ['order_id' => $order->increment_id]))
->view('shop::emails.sales.new-inventorysource-shipment');
}
}

View File

@ -31,8 +31,8 @@ class NewInvoiceNotification extends Mailable
$order = $this->invoice->order;
return $this->from(core()->getSenderEmailDetails()['email'], core()->getSenderEmailDetails()['name'])
->to($order->customer_email, $order->customer_full_name)
->subject(trans('shop::app.mail.invoice.subject', ['order_id' => $order->increment_id]))
->view('shop::emails.sales.new-invoice');
->to($order->customer_email, $order->customer_full_name)
->subject(trans('shop::app.mail.invoice.subject', ['order_id' => $order->increment_id]))
->view('shop::emails.sales.new-invoice');
}
}

View File

@ -29,8 +29,8 @@ class NewOrderNotification extends Mailable
public function build()
{
return $this->from(core()->getSenderEmailDetails()['email'], core()->getSenderEmailDetails()['name'])
->to($this->order->customer_email, $this->order->customer_full_name)
->subject(trans('shop::app.mail.order.subject'))
->view('shop::emails.sales.new-order');
->to($this->order->customer_email, $this->order->customer_full_name)
->subject(trans('shop::app.mail.order.subject'))
->view('shop::emails.sales.new-order');
}
}

View File

@ -31,8 +31,8 @@ class NewRefundNotification extends Mailable
$order = $this->refund->order;
return $this->from(core()->getSenderEmailDetails()['email'], core()->getSenderEmailDetails()['name'])
->to($order->customer_email, $order->customer_full_name)
->subject(trans('shop::app.mail.refund.subject', ['order_id' => $order->increment_id]))
->view('shop::emails.sales.new-refund');
->to($order->customer_email, $order->customer_full_name)
->subject(trans('shop::app.mail.refund.subject', ['order_id' => $order->increment_id]))
->view('shop::emails.sales.new-refund');
}
}

View File

@ -31,8 +31,8 @@ class NewShipmentNotification extends Mailable
$order = $this->shipment->order;
return $this->from(core()->getSenderEmailDetails()['email'], core()->getSenderEmailDetails()['name'])
->to($order->customer_email, $order->customer_full_name)
->subject(trans('shop::app.mail.shipment.subject', ['order_id' => $order->increment_id]))
->view('shop::emails.sales.new-shipment');
->to($order->customer_email, $order->customer_full_name)
->subject(trans('shop::app.mail.shipment.subject', ['order_id' => $order->increment_id]))
->view('shop::emails.sales.new-shipment');
}
}

View File

@ -29,8 +29,8 @@ class OrderCommentNotification extends Mailable
public function build()
{
return $this->from(core()->getSenderEmailDetails()['email'], core()->getSenderEmailDetails()['name'])
->to($this->comment->order->customer_email, $this->comment->order->customer_full_name)
->subject(trans('shop::app.mail.order.comment.subject', ['order_id' => $this->comment->order->increment_id]))
->view('shop::emails.sales.new-order-comment');
->to($this->comment->order->customer_email, $this->comment->order->customer_full_name)
->subject(trans('shop::app.mail.order.comment.subject', ['order_id' => $this->comment->order->increment_id]))
->view('shop::emails.sales.new-order-comment');
}
}

View File

@ -105,13 +105,15 @@ class AdminServiceProvider extends ServiceProvider
&& substr_count($item['key'], '.') == 1
) {
foreach ($allowedPermissions as $key => $value) {
if ($item['key'] == $value) {
$neededItem = $allowedPermissions[$key + 1];
if ($item['key'] != $value) {
continue;
}
foreach (config('menu.admin') as $key1 => $findMatced) {
if ($findMatced['key'] == $neededItem) {
$item['route'] = $findMatced['route'];
}
$neededItem = $allowedPermissions[$key + 1];
foreach (config('menu.admin') as $key1 => $findMatced) {
if ($findMatced['key'] == $neededItem) {
$item['route'] = $findMatced['route'];
}
}
}

View File

@ -240,7 +240,7 @@
<script>
var groups = @json($attributeFamily ? $attributeFamily->attribute_groups : []);
var custom_attributes = @json($custom_attributes);
var custom_attributes = @json($customAttributes);
Vue.component('group-list', {

View File

@ -237,7 +237,7 @@
<script>
var groups = @json($attributeFamily->attribute_groups);
var custom_attributes = @json($custom_attributes);
var custom_attributes = @json($customAttributes);
Vue.component('group-list', {

View File

@ -89,7 +89,7 @@
<div class="control-group">
<label for="customerGroup" >{{ __('admin::app.customers.customers.customer_group') }}</label>
<select class="control" id="customerGroup" name="customer_group_id">
@foreach ($customerGroup as $group)
@foreach ($groups as $group)
<option value="{{ $group->id }}"> {{ $group->name}} </>
@endforeach
</select>

View File

@ -168,7 +168,7 @@
@endif
<select class="control" id="customerGroup" name="customer_group_id">
@foreach ($customerGroup as $group)
@foreach ($groups as $group)
<option value="{{ $group->id }}" {{ $selectedCustomerOption == $group->id ? 'selected' : '' }}>
{{ $group->name}}
</option>

View File

@ -62,11 +62,9 @@ class AttributeController extends Controller
'type' => 'required',
]);
$data = request()->all();
$data['is_user_defined'] = 1;
$this->attributeRepository->create($data);
$this->attributeRepository->create(array_merge(request()->all(), [
'is_user_defined' => 1,
]));
session()->flash('success', trans('admin::app.response.create-success', ['name' => 'Attribute']));
@ -170,12 +168,10 @@ class AttributeController extends Controller
}
session()->flash('success', trans('admin::app.datagrid.mass-ops.delete-success', ['resource' => 'attributes']));
return redirect()->back();
} else {
session()->flash('error', trans('admin::app.datagrid.mass-ops.method-error'));
return redirect()->back();
}
return redirect()->back();
}
}

View File

@ -53,9 +53,9 @@ class AttributeFamilyController extends Controller
{
$attributeFamily = $this->attributeFamilyRepository->with(['attribute_groups.custom_attributes'])->findOneByField('code', 'default');
$custom_attributes = $this->attributeRepository->all(['id', 'code', 'admin_name', 'type']);
$customAttributes = $this->attributeRepository->all(['id', 'code', 'admin_name', 'type']);
return view($this->_config['view'], compact('custom_attributes', 'attributeFamily'));
return view($this->_config['view'], compact('attributeFamily', 'customAttributes'));
}
/**
@ -87,9 +87,9 @@ class AttributeFamilyController extends Controller
{
$attributeFamily = $this->attributeFamilyRepository->with(['attribute_groups.custom_attributes'])->findOrFail($id, ['*']);
$custom_attributes = $this->attributeRepository->all(['id', 'code', 'admin_name', 'type']);
$customAttributes = $this->attributeRepository->all(['id', 'code', 'admin_name', 'type']);
return view($this->_config['view'], compact('attributeFamily', 'custom_attributes'));
return view($this->_config['view'], compact('attributeFamily', 'customAttributes'));
}
/**

View File

@ -2,29 +2,30 @@
namespace Webkul\Attribute\Repositories;
use Webkul\Core\Eloquent\Repository;
use Illuminate\Container\Container;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Str;
use Webkul\Core\Eloquent\Repository;
use Webkul\Attribute\Repositories\AttributeRepository;
use Webkul\Attribute\Repositories\AttributeGroupRepository;
use Illuminate\Container\Container as App;
use Illuminate\Support\Str;
class AttributeFamilyRepository extends Repository
{
/**
* Create a new controller instance.
* Create a new repository instance.
*
* @param \Webkul\Attribute\Repositories\AttributeRepository $attributeRepository
* @param \Webkul\Attribute\Repositories\AttributeGroupRepository $attributeGroupRepository
* @param \Illuminate\Container\Container $container
* @return void
*/
public function __construct(
protected AttributeRepository $attributeRepository,
protected AttributeGroupRepository $attributeGroupRepository,
App $app
Container $container
)
{
parent::__construct($app);
parent::__construct($container);
}
/**

View File

@ -2,7 +2,7 @@
namespace Webkul\Attribute\Repositories;
use Illuminate\Container\Container as App;
use Illuminate\Container\Container;
use Illuminate\Support\Facades\Event;
use Webkul\Attribute\Repositories\AttributeOptionRepository;
use Webkul\Core\Eloquent\Repository;
@ -13,14 +13,15 @@ class AttributeRepository extends Repository
* Create a new repository instance.
*
* @param \Webkul\Attribute\Repositories\AttributeOptionRepository $attributeOptionRepository
* @param \Illuminate\Container\Container $container
* @return void
*/
public function __construct(
protected AttributeOptionRepository $attributeOptionRepository,
App $app
Container $container
)
{
parent::__construct($app);
parent::__construct($container);
}
/**
@ -260,29 +261,19 @@ class AttributeRepository extends Repository
foreach ($attributes as $key => $attribute) {
if (
$attribute->code != 'tax_category_id'
&& ($attribute->type == 'select'
|| $attribute->type == 'multiselect'
|| $attribute->code == 'sku')
&& (
in_array($attribute->type ,['select', 'multiselect'])
|| $attribute->code == 'sku'
)
) {
if ($attribute->options()->exists()) {
array_push($trimmed, [
'id' => $attribute->id,
'name' => $attribute->admin_name,
'type' => $attribute->type,
'code' => $attribute->code,
'has_options' => true,
'options' => $attribute->options,
]);
} else {
array_push($trimmed, [
'id' => $attribute->id,
'name' => $attribute->admin_name,
'type' => $attribute->type,
'code' => $attribute->code,
'has_options' => false,
'options' => null,
]);
}
array_push($trimmed, [
'id' => $attribute->id,
'name' => $attribute->admin_name,
'type' => $attribute->type,
'code' => $attribute->code,
'has_options' => $attribute->options()->exists(),
'options' => $attribute->options,
]);
}
}

View File

@ -57,8 +57,6 @@ class PageController extends Controller
*/
public function store()
{
$data = request()->all();
$this->validate(request(), [
'url_key' => ['required', 'unique:cms_page_translations,url_key', new \Webkul\Core\Contracts\Validations\Slug],
'page_title' => 'required',

View File

@ -53,10 +53,10 @@ class CartRule
{
$appliedCartRuleIds = [];
$this->calculateCartItemTotals($cart, $cart->items);
$this->calculateCartItemTotals($cart);
foreach ($cart->items as $item) {
$itemCartRuleIds = $this->process($cart, $item);
$itemCartRuleIds = $this->process($item);
$appliedCartRuleIds = array_merge($appliedCartRuleIds, $itemCartRuleIds);
@ -132,41 +132,41 @@ class CartRule
public function canProcessRule($cart, $rule): bool
{
if ($rule->coupon_type) {
if (strlen($cart->coupon_code)) {
/** @var \Webkul\CartRule\Models\CartRule $rule */
// Laravel relation is used instead of repository for performance
// reasons (cart_rule_coupon-relation is pre-loaded by self::getCartRuleQuery())
$coupon = $rule->cart_rule_coupon()->where('code', $cart->coupon_code)->first();
if (! strlen($cart->coupon_code)) {
return false;
}
/** @var \Webkul\CartRule\Models\CartRule $rule */
// Laravel relation is used instead of repository for performance
// reasons (cart_rule_coupon-relation is pre-loaded by self::getCartRuleQuery())
$coupon = $rule->cart_rule_coupon()->where('code', $cart->coupon_code)->first();
if (
$coupon
&& $coupon->code === $cart->coupon_code
) {
if (
$coupon->usage_limit
&& $coupon->times_used >= $coupon->usage_limit
) {
return false;
}
if (
$coupon
&& $coupon->code === $cart->coupon_code
$cart->customer_id
&& $coupon->usage_per_customer
) {
$couponUsage = $this->cartRuleCouponUsageRepository->findOneWhere([
'cart_rule_coupon_id' => $coupon->id,
'customer_id' => $cart->customer_id,
]);
if (
$coupon->usage_limit
&& $coupon->times_used >= $coupon->usage_limit
$couponUsage
&& $couponUsage->times_used >= $coupon->usage_per_customer
) {
return false;
}
if (
$cart->customer_id
&& $coupon->usage_per_customer
) {
$couponUsage = $this->cartRuleCouponUsageRepository->findOneWhere([
'cart_rule_coupon_id' => $coupon->id,
'customer_id' => $cart->customer_id,
]);
if (
$couponUsage
&& $couponUsage->times_used >= $coupon->usage_per_customer
) {
return false;
}
}
} else {
return false;
}
} else {
return false;
@ -193,11 +193,10 @@ class CartRule
/**
* Cart item discount calculation process
*
* @param \Webkul\Checkout\Contracts\Cart $cart
* @param \Webkul\Checkout\Models\CartItem $item
* @return array
*/
public function process($cart, CartItem $item): array
public function process(CartItem $item): array
{
$item->discount_percent = 0;
$item->discount_amount = 0;
@ -205,8 +204,8 @@ class CartRule
$appliedRuleIds = [];
foreach ($rules = $this->getCartRules($cart) as $rule) {
if (! $this->canProcessRule($cart, $rule)) {
foreach ($rules = $this->getCartRules($item->cart) as $rule) {
if (! $this->canProcessRule($item->cart, $rule)) {
continue;
}
@ -319,7 +318,7 @@ class CartRule
* Cart shipping discount calculation process
*
* @param \Webkul\Checkout\Contracts\Cart $cart
* @return void
* @return self|void
*/
public function processShippingDiscount($cart)
{
@ -418,9 +417,7 @@ class CartRule
$appliedRuleIds = [];
foreach ($cart->items->all() as $item) {
foreach ($this->getCartRules($cart) as $rule) {
if (! $this->canProcessRule($cart, $rule)) {
continue;
}
@ -466,36 +463,37 @@ class CartRule
* Calculate cart item totals for each rule
*
* @param \Webkul\Checkout\Contracts\Cart $cart
* @param \Illuminate\Support\Collecton $items
* @return \Webkul\Rule\Helpers\Validator
* @return array|void
*/
public function calculateCartItemTotals($cart, $items)
public function calculateCartItemTotals($cart)
{
foreach ($this->getCartRules($cart) as $rule) {
if ($rule->action_type == 'cart_fixed') {
$totalPrice = $totalBasePrice = $validCount = 0;
if ($rule->action_type != 'cart_fixed') {
continue;
}
foreach ($items as $item) {
if (! $this->canProcessRule($cart, $rule)) {
continue;
}
$totalPrice = $totalBasePrice = $validCount = 0;
if (! $this->validator->validate($rule, $item)) {
continue;
}
$quantity = $rule->discount_quantity ? min($item->quantity, $rule->discount_quantity) : $item->quantity;
$totalBasePrice += $item->base_price * $quantity;
$validCount++;
foreach ($cart->items as $item) {
if (! $this->canProcessRule($cart, $rule)) {
continue;
}
$this->itemTotals[$rule->id] = [
'base_total_price' => $totalBasePrice,
'total_items' => $validCount,
];
if (! $this->validator->validate($rule, $item)) {
continue;
}
$quantity = $rule->discount_quantity ? min($item->quantity, $rule->discount_quantity) : $item->quantity;
$totalBasePrice += $item->base_price * $quantity;
$validCount++;
}
$this->itemTotals[$rule->id] = [
'base_total_price' => $totalBasePrice,
'total_items' => $validCount,
];
}
}
@ -546,9 +544,8 @@ class CartRule
}
/**
* @param $customerGroupId
* @param $channelId
*
* @param integer $customerGroupId
* @param integer $channelId
* @return \Illuminate\Database\Eloquent\Collection
*/
public function getCartRuleQuery($customerGroupId, $channelId): \Illuminate\Database\Eloquent\Collection

View File

@ -99,9 +99,7 @@ class CartRuleController extends Controller
public function store(CartRuleRequest $cartRuleRequest)
{
try {
$data = $cartRuleRequest->all();
$this->cartRuleRepository->create($data);
$this->cartRuleRepository->create($cartRuleRequest->all());
session()->flash('success', trans('admin::app.response.create-success', ['name' => 'Cart Rule']));

View File

@ -41,7 +41,10 @@ class CartRuleRequest extends FormRequest
]);
}
if (request()->has('action_type') && request()->action_type == 'by_percent') {
if (
request()->has('action_type')
&& request()->action_type == 'by_percent'
) {
$rules = array_merge($rules, [
'discount_amount' => 'required|numeric|min:0|max:100',
]);

View File

@ -63,7 +63,7 @@ class CartRuleRepository extends Repository
$data['ends_till'] = isset($data['ends_till']) && $data['ends_till'] ? $data['ends_till'] : null;
$data['status'] = ! isset($data['status']) ? 0 : 1;
$data['status'] = isset($data['status']);
$cartRule = parent::create($data);
@ -100,13 +100,12 @@ class CartRuleRepository extends Repository
{
Event::dispatch('promotions.cart_rule.update.before', $id);
$data['starts_from'] = $data['starts_from'] ?: null;
$data['ends_till'] = $data['ends_till'] ?: null;
$data['status'] = ! isset($data['status']) ? 0 : 1;
$data['conditions'] = $data['conditions'] ?? [];
$data = array_merge($data, [
'starts_from' => $data['starts_from'] ?: null,
'ends_till' => $data['ends_till'] ?: null,
'status' => isset($data['status']),
'conditions' => $data['conditions'] ?? [],
]);
$cartRule = $this->find($id);
@ -118,7 +117,10 @@ class CartRuleRepository extends Repository
if ($data['coupon_type']) {
if (! $data['use_auto_generation']) {
$cartRuleCoupon = $this->cartRuleCouponRepository->findOneWhere(['is_primary' => 1, 'cart_rule_id' => $cartRule->id]);
$cartRuleCoupon = $this->cartRuleCouponRepository->findOneWhere([
'is_primary' => 1,
'cart_rule_id' => $cartRule->id,
]);
if ($cartRuleCoupon) {
$this->cartRuleCouponRepository->update([
@ -138,7 +140,10 @@ class CartRuleRepository extends Repository
]);
}
} else {
$this->cartRuleCouponRepository->deleteWhere(['is_primary' => 1, 'cart_rule_id' => $cartRule->id]);
$this->cartRuleCouponRepository->deleteWhere([
'is_primary' => 1,
'cart_rule_id' => $cartRule->id,
]);
$this->cartRuleCouponRepository->getModel()->where('cart_rule_id', $cartRule->id)->update([
'usage_limit' => $data['uses_per_coupon'] ?? 0,
@ -282,9 +287,7 @@ class CartRuleRepository extends Repository
if ($attribute->validation == 'decimal') {
$attributeType = 'decimal';
}
if ($attribute->validation == 'numeric') {
} elseif ($attribute->validation == 'numeric') {
$attributeType = 'integer';
}

View File

@ -57,8 +57,8 @@ class CatalogRuleIndex
}
$productIds = $product->getTypeInstance()->isComposite()
? $product->getTypeInstance()->getChildrenIds()
: [$product->id];
? $product->getTypeInstance()->getChildrenIds()
: [$product->id];
$this->cleanIndexes($productIds);
@ -100,14 +100,14 @@ class CatalogRuleIndex
$catalogRules = $this->catalogRuleRepository->scopeQuery(function($query) {
return $query->where(function ($query1) {
$query1->where('catalog_rules.starts_from', '<=', Carbon::now()->format('Y-m-d'))
->orWhereNull('catalog_rules.starts_from');
})
->where(function ($query2) {
$query2->where('catalog_rules.ends_till', '>=', Carbon::now()->format('Y-m-d'))
->orWhereNull('catalog_rules.ends_till');
})
->orderBy('sort_order', 'asc');
$query1->where('catalog_rules.starts_from', '<=', Carbon::now()->format('Y-m-d'))
->orWhereNull('catalog_rules.starts_from');
})
->where(function ($query2) {
$query2->where('catalog_rules.ends_till', '>=', Carbon::now()->format('Y-m-d'))
->orWhereNull('catalog_rules.ends_till');
})
->orderBy('sort_order', 'asc');
})->findWhere(['status' => 1]);
return $catalogRules;

View File

@ -38,8 +38,9 @@ class CatalogRuleProduct
*/
public function insertRuleProduct($rule, $batchCount = 1000, $product = null)
{
if (! (float) $rule->discount_amount)
if (! (float) $rule->discount_amount) {
return;
}
$productIds = $this->getMatchingProductIds($rule, $product);
@ -90,10 +91,10 @@ class CatalogRuleProduct
{
$qb = $this->productRepository->scopeQuery(function($query) use($rule, $product) {
$qb = $query->distinct()
->addSelect('products.*')
->leftJoin('product_flat', 'products.id', '=', 'product_flat.product_id')
->leftJoin('channels', 'product_flat.channel', '=', 'channels.code')
->whereIn('channels.id', $rule->channels()->pluck('id')->toArray());
->addSelect('products.*')
->leftJoin('product_flat', 'products.id', '=', 'product_flat.product_id')
->leftJoin('channels', 'product_flat.channel', '=', 'channels.code')
->whereIn('channels.id', $rule->channels()->pluck('id')->toArray());
if ($product) {
$qb->where('products.id', $product->id);
@ -162,7 +163,7 @@ class CatalogRuleProduct
$query = $query->leftJoin('product_attribute_values as ' . 'pav_' . $attribute->code, function($qb) use($attribute) {
$qb = $qb->where('pav_' . $attribute->code . '.channel', $attribute->value_per_channel ? core()->getDefaultChannelCode() : null)
->where('pav_' . $attribute->code . '.locale', $attribute->value_per_locale ? app()->getLocale() : null);
->where('pav_' . $attribute->code . '.locale', $attribute->value_per_locale ? app()->getLocale() : null);
$qb->on('products.id', 'pav_' . $attribute->code . '.product_id')
->where('pav_' . $attribute->code . '.attribute_id', $attribute->id);
@ -183,13 +184,13 @@ class CatalogRuleProduct
{
$results = $this->catalogRuleProductRepository->scopeQuery(function($query) use($product) {
$qb = $query->distinct()
->select('catalog_rule_products.*')
->leftJoin('products', 'catalog_rule_products.product_id', '=', 'products.id')
->orderBy('channel_id', 'asc')
->orderBy('customer_group_id', 'asc')
->orderBy('product_id', 'asc')
->orderBy('sort_order', 'asc')
->orderBy('catalog_rule_id', 'asc');
->select('catalog_rule_products.*')
->leftJoin('products', 'catalog_rule_products.product_id', '=', 'products.id')
->orderBy('channel_id', 'asc')
->orderBy('customer_group_id', 'asc')
->orderBy('product_id', 'asc')
->orderBy('sort_order', 'asc')
->orderBy('catalog_rule_id', 'asc');
$qb = $this->addAttributeToSelect('price', $qb);

View File

@ -64,9 +64,7 @@ class CatalogRuleController extends Controller
*/
public function store(CatalogRuleRequest $catalogRuleRequest)
{
$data = $catalogRuleRequest->all();
$this->catalogRuleRepository->create($data);
$this->catalogRuleRepository->create($catalogRuleRequest->all());
$this->catalogRuleIndexHelper->reindexComplete();

View File

@ -53,11 +53,11 @@ class CatalogRuleRepository extends Repository
{
Event::dispatch('promotions.catalog_rule.create.before');
$data['starts_from'] = $data['starts_from'] ?: null;
$data['ends_till'] = $data['ends_till'] ?: null;
$data['status'] = ! isset($data['status']) ? 0 : 1;
$data = array_merge($data, [
'starts_from' => $data['starts_from'] ?: null,
'ends_till' => $data['ends_till'] ?: null,
'status' => isset($data['status']),
]);
$catalogRule = parent::create($data);
@ -82,13 +82,12 @@ class CatalogRuleRepository extends Repository
{
Event::dispatch('promotions.catalog_rule.update.before', $id);
$data['starts_from'] = $data['starts_from'] ?: null;
$data['ends_till'] = $data['ends_till'] ?: null;
$data['status'] = ! isset($data['status']) ? 0 : 1;
$data['conditions'] = $data['conditions'] ?? [];
$data = array_merge($data, [
'starts_from' => $data['starts_from'] ?: null,
'ends_till' => $data['ends_till'] ?: null,
'status' => isset($data['status']),
'conditions' => $data['conditions'] ?? [],
]);
$catalogRule = $this->find($id);

View File

@ -153,6 +153,7 @@ class CategoryController extends Controller
public function massDestroy()
{
$suppressFlash = true;
$categoryIds = explode(',', request()->input('indexes'));
foreach ($categoryIds as $categoryId) {

View File

@ -41,6 +41,7 @@ class CategoryRepository extends Repository
foreach ($model->translatedAttributes as $attribute) {
if (isset($data[$attribute])) {
$data[$locale->code][$attribute] = $data[$attribute];
$data[$locale->code]['locale_id'] = $locale->id;
}
}
@ -237,6 +238,7 @@ class CategoryRepository extends Repository
foreach ($data[$type] as $imageId => $image) {
$file = $type . '.' . $imageId;
$dir = 'category/' . $category->id;
if ($request->hasFile($file)) {
@ -245,6 +247,7 @@ class CategoryRepository extends Repository
}
$category->{$type} = $request->file($file)->store($dir);
$category->save();
}
}
@ -254,6 +257,7 @@ class CategoryRepository extends Repository
}
$category->{$type} = null;
$category->save();
}
}

View File

@ -420,8 +420,7 @@ class Cart
&& (
$user->email
&& $user->first_name
&&
$user->last_name
&& $user->last_name
)
) {
$cart->customer_email = $user->email;

View File

@ -18,24 +18,6 @@ class CartItemRepository extends Repository
return 'Webkul\Checkout\Contracts\CartItem';
}
/**
* @param array $data
* @param $id
* @param string $attribute
*
* @return \Webkul\Checkout\Contracts\CartItem|null
*/
public function update(array $data, $id, $attribute = "id"): ?CartItem
{
$item = $this->find($id);
if ($item) {
$item->update($data);
}
return $item;
}
/**
* @param int $cartItemId
* @return int

View File

@ -17,32 +17,6 @@ class CartRepository extends Repository
return 'Webkul\Checkout\Contracts\Cart';
}
/**
* @param array $data
* @return \Webkul\Checkout\Contracts\Cart
*/
public function create(array $data)
{
$cart = $this->model->create($data);
return $cart;
}
/**
* @param array $data
* @param int $id
* @param string $attribute
* @return \Webkul\Checkout\Contracts\Cart
*/
public function update(array $data, $id, $attribute = "id")
{
$cart = $this->find($id);
$cart->update($data);
return $cart;
}
/**
* Method to detach associations. Use this only with guest cart only.
*

View File

@ -196,7 +196,10 @@ trait CartTools
}
if (! $wishlistItem->additional) {
$wishlistItem->additional = ['product_id' => $wishlistItem->product_id, 'quantity' => 1];
$wishlistItem->additional = [
'product_id' => $wishlistItem->product_id,
'quantity' => 1,
];
}
request()->merge($wishlistItem->additional);

View File

@ -27,7 +27,7 @@ trait CartValidators
$count = $cart->all_items()->where('product_id', $product->id)->count();
return $count > 0 ? true : false;
return $count > 0;
}
/**
@ -37,11 +37,9 @@ trait CartValidators
*/
public function hasError(): bool
{
if (! $this->getCart()) {
return true;
}
if (! $this->isItemsHaveSufficientQuantity()) {
if (
! $this->getCart()
|| ! $this->isItemsHaveSufficientQuantity()) {
return true;
}

View File

@ -64,11 +64,15 @@ class BookingCron extends Command
ProductFlat::query()->where('product_id', $expEvent->product_id)
->update(['status' => 0]);
Log::info('BookingCron: deactivated expired event', ['booking_product_id' => $expEvent->id, 'product_id' => $expEvent->product_id]);
Log::info('BookingCron: deactivated expired event', [
'booking_product_id' => $expEvent->id,
'product_id' => $expEvent->product_id,
]);
}
$this->info('All expired events have been deactivated');
} else {
Log::info('BookingCron: Did not find any expired events to be deactivated');
$this->info('Did not find any expired events to be deactivated');
}
}

View File

@ -2,6 +2,7 @@
namespace Webkul\Core\Http\Controllers;
use Illuminate\Support\Facades\Event;
use Webkul\Admin\DataGrids\ExchangeRatesDataGrid;
use Webkul\Core\Repositories\CurrencyRepository;
use Webkul\Core\Repositories\ExchangeRateRepository;
@ -68,7 +69,12 @@ class ExchangeRateController extends Controller
'rate' => 'required|numeric',
]);
$this->exchangeRateRepository->create(request()->all());
Event::dispatch('core.exchange_rate.create.before');
$exchangeRate = $this->exchangeRateRepository->create(request()->all());
Event::dispatch('core.exchange_rate.create.after', $exchangeRate);
session()->flash('success', trans('admin::app.settings.exchange_rates.create-success'));
@ -103,7 +109,11 @@ class ExchangeRateController extends Controller
'rate' => 'required|numeric',
]);
$this->exchangeRateRepository->update(request()->all(), $id);
Event::dispatch('core.exchange_rate.update.before', $id);
$exchangeRate = $this->exchangeRateRepository->update(request()->all(), $id);
Event::dispatch('core.exchange_rate.update.after', $exchangeRate);
session()->flash('success', trans('admin::app.settings.exchange_rates.update-success'));
@ -139,8 +149,12 @@ class ExchangeRateController extends Controller
$this->exchangeRateRepository->findOrFail($id);
try {
Event::dispatch('core.exchange_rate.delete.before', $id);
$this->exchangeRateRepository->delete($id);
Event::dispatch('core.exchange_rate.delete.after', $id);
return response()->json(['message' => trans('admin::app.settings.exchange_rates.delete-success')]);
} catch (\Exception $e) {
report($e);

View File

@ -60,18 +60,17 @@ class SubscriptionController extends Controller
*/
public function update($id)
{
$data = request()->all();
$subscriber = $this->subscribersListRepository->findOrFail($id);
$customer = $subscriber->customer;
if (! is_null($customer)) {
$customer->subscribed_to_news_letter = $data['is_subscribed'];
$customer->subscribed_to_news_letter = request('is_subscribed');
$customer->save();
}
$result = $subscriber->update($data);
$result = $subscriber->update(request()->all());
if ($result) {
session()->flash('success', trans('admin::app.customers.subscribers.update-success'));

View File

@ -2,7 +2,6 @@
namespace Webkul\Core\Repositories;
use Illuminate\Support\Facades\Event;
use Prettus\Repository\Traits\CacheableRepository;
use Webkul\Core\Eloquent\Repository;
@ -19,54 +18,4 @@ class ExchangeRateRepository extends Repository
{
return \Webkul\Core\Contracts\CurrencyExchangeRate::class;
}
/**
* Create.
*
* @param array $attributes
* @return mixed
*/
public function create(array $attributes)
{
Event::dispatch('core.exchange_rate.create.before');
$exchangeRate = parent::create($attributes);
Event::dispatch('core.exchange_rate.create.after', $exchangeRate);
return $exchangeRate;
}
/**
* Update.
*
* @param array $attributes
* @param $id
* @return mixed
*/
public function update(array $attributes, $id)
{
Event::dispatch('core.exchange_rate.update.before', $id);
$exchangeRate = parent::update($attributes, $id);
Event::dispatch('core.exchange_rate.update.after', $exchangeRate);
return $exchangeRate;
}
/**
* Delete.
*
* @param int $id
* @return bool
*/
public function delete($id)
{
Event::dispatch('core.exchange_rate.delete.before', $id);
parent::delete($id);
Event::dispatch('core.exchange_rate.delete.after', $id);
}
}

View File

@ -117,7 +117,7 @@ class Captcha implements CaptchaContract
$response = $client->post($this->getSiteVerifyEndpoint(), [
'query' => [
'secret' => $this->secretKey,
'secret' => $this->secretKey,
'response' => $response
]
]);
@ -160,7 +160,7 @@ class Captcha implements CaptchaContract
protected function getAttributes(): array
{
return [
'class' => 'g-recaptcha',
'class' => 'g-recaptcha',
'data-sitekey' => $this->siteKey,
];
}

View File

@ -16,13 +16,6 @@ class WishlistController extends Controller
*/
protected $_config;
/**
* Current customer.
*
* @var \Webkul\Customer\Models\Customer
*/
protected $currentCustomer;
/**
* Create a new controller instance.
*
@ -52,9 +45,9 @@ class WishlistController extends Controller
}
return view($this->_config['view'], [
'items' => $this->wishlistRepository->getCustomerWishlist(),
'isSharingEnabled' => $this->isSharingEnabled(),
'isWishlistShared' => $customer->isWishlistShared(),
'items' => $this->wishlistRepository->getCustomerWishlist(),
'isSharingEnabled' => $this->isSharingEnabled(),
'isWishlistShared' => $customer->isWishlistShared(),
'wishlistSharedLink' => $customer->getWishlistSharedLink()
]);
}
@ -62,17 +55,18 @@ class WishlistController extends Controller
/**
* Function to add item to the wishlist.
*
* @param int $itemId
* @param int $productId
* @return \Illuminate\Http\Response
*/
public function add($itemId)
public function add($productId)
{
$customer = auth()->guard('customer')->user();
$product = $this->productRepository->find($itemId);
$product = $this->productRepository->find($productId);
if ( $product == null ) {
if (! $product) {
session()->flash('error', trans('customer::app.product-removed'));
return redirect()->back();
} elseif (! $product->status) {
return redirect()->back();
@ -80,34 +74,31 @@ class WishlistController extends Controller
$data = [
'channel_id' => core()->getCurrentChannel()->id,
'product_id' => $itemId,
'product_id' => $productId,
'customer_id' => $customer->id,
];
$checked = $this->wishlistRepository->findWhere([
'channel_id' => core()->getCurrentChannel()->id,
'product_id' => $itemId,
'customer_id' => $customer->id,
]);
$wishlist = $this->wishlistRepository->findOneWhere($data);
if (
$product->parent
&& $product->parent->type !== 'configurable'
) {
$product = $this->productRepository->find($product->parent_id);
$data['product_id'] = $product->id;
}
if ($checked->isEmpty()) {
if ($this->wishlistRepository->create($data)) {
session()->flash('success', trans('customer::app.wishlist.success'));
if (! $wishlist) {
$wishlist = $this->wishlistRepository->create($data);
return redirect()->back();
if ($wishlist) {
session()->flash('success', trans('customer::app.wishlist.success'));
} else {
session()->flash('error', trans('customer::app.wishlist.failure'));
return redirect()->back();
}
return redirect()->back();
} else {
$this->wishlistRepository->findOneWhere([
'product_id' => $data['product_id']
@ -140,7 +131,7 @@ class WishlistController extends Controller
&& $updateCounts > 0
) {
return response()->json([
'isWishlistShared' => $customer->isWishlistShared(),
'isWishlistShared' => $customer->isWishlistShared(),
'wishlistSharedLink' => $customer->getWishlistSharedLink()
]);
}
@ -257,12 +248,8 @@ class WishlistController extends Controller
{
$customer = auth()->guard('customer')->user();
$wishlistItems = $customer->wishlist_items;
if ($wishlistItems->count() > 0) {
foreach ($wishlistItems as $wishlistItem) {
$this->wishlistRepository->delete($wishlistItem->id);
}
foreach ($customer->wishlist_items as $wishlistItem) {
$this->wishlistRepository->delete($wishlistItem->id);
}
session()->flash('success', trans('customer::app.wishlist.remove-all-success'));
@ -277,8 +264,6 @@ class WishlistController extends Controller
*/
public function isSharingEnabled(): bool
{
return (bool) core()->getConfigData('customer.settings.wishlist.share')
? true
: false;
return (bool) core()->getConfigData('customer.settings.wishlist.share');
}
}

View File

@ -35,7 +35,6 @@ class VerificationEmail extends Mailable
->with('data', [
'email' => $this->verificationData['email'],
'token' => $this->verificationData['token'],
]
);
]);
}
}

View File

@ -26,7 +26,6 @@ class CustomerResetPassword extends ResetPassword
->view('shop::emails.customer.forget-password', [
'user_name' => $notifiable->name,
'token' => $this->token,
]
);
]);
}
}

View File

@ -28,8 +28,8 @@ class CustomerUpdatePassword extends Mailable
public function build()
{
return $this->from(core()->getSenderEmailDetails()['email'], core()->getSenderEmailDetails()['name'])
->to($this->customer->email, $this->customer->name)
->subject(trans('shop::app.mail.update-password.subject'))
->view('shop::emails.customer.update-password', ['user' => $this->customer]);
->to($this->customer->email, $this->customer->name)
->subject(trans('shop::app.mail.update-password.subject'))
->view('shop::emails.customer.update-password', ['user' => $this->customer]);
}
}

View File

@ -2,9 +2,9 @@
namespace Webkul\Sitemap\Providers;
use Konekt\Concord\BaseModuleServiceProvider;
use Webkul\Core\Providers\CoreModuleServiceProvider;
class ModuleServiceProvider extends BaseModuleServiceProvider
class ModuleServiceProvider extends CoreModuleServiceProvider
{
protected $models = [
\Webkul\Sitemap\Models\Sitemap::class