Optimized and refactored code
This commit is contained in:
parent
809a215730
commit
acf9626219
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Webkul\Admin\Http\Controllers\Customer;
|
||||
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Webkul\Customer\Rules\VatIdRule;
|
||||
use Webkul\Admin\DataGrids\AddressDataGrid;
|
||||
use Webkul\Admin\Http\Controllers\Controller;
|
||||
|
|
@ -84,15 +85,15 @@ class AddressController extends Controller
|
|||
'vat_id' => new VatIdRule(),
|
||||
]);
|
||||
|
||||
if ($this->customerAddressRepository->create(request()->all())) {
|
||||
session()->flash('success', trans('admin::app.customers.addresses.success-create'));
|
||||
Event::dispatch('customer.addresses.create.before');
|
||||
|
||||
return redirect()->route('admin.customer.edit', ['id' => request('customer_id')]);
|
||||
} else {
|
||||
session()->flash('success', trans('admin::app.customers.addresses.error-create'));
|
||||
$customerAddress = $this->customerAddressRepository->create(request()->all());
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
Event::dispatch('customer.addresses.create.after', $customerAddress);
|
||||
|
||||
session()->flash('success', trans('admin::app.customers.addresses.success-create'));
|
||||
|
||||
return redirect()->route('admin.customer.edit', ['id' => request('customer_id')]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -129,7 +130,11 @@ class AddressController extends Controller
|
|||
'vat_id' => new VatIdRule(),
|
||||
]);
|
||||
|
||||
$this->customerAddressRepository->update(request()->all(), $id);
|
||||
Event::dispatch('customer.addresses.update.before', $id);
|
||||
|
||||
$customerAddress = $this->customerAddressRepository->update(request()->all(), $id);
|
||||
|
||||
Event::dispatch('customer.addresses.update.after', $customerAddress);
|
||||
|
||||
session()->flash('success', trans('admin::app.customers.addresses.success-update'));
|
||||
|
||||
|
|
@ -144,8 +149,12 @@ class AddressController extends Controller
|
|||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
Event::dispatch('customer.addresses.delete.before', $id);
|
||||
|
||||
$this->customerAddressRepository->delete($id);
|
||||
|
||||
Event::dispatch('customer.addresses.delete.after', $id);
|
||||
|
||||
return response()->json([
|
||||
'redirect' => false,
|
||||
'message' => trans('admin::app.customers.addresses.success-delete')
|
||||
|
|
@ -163,7 +172,11 @@ class AddressController extends Controller
|
|||
$addressIds = explode(',', request()->input('indexes'));
|
||||
|
||||
foreach ($addressIds as $addressId) {
|
||||
Event::dispatch('customer.addresses.delete.before', $addressId);
|
||||
|
||||
$this->customerAddressRepository->delete($addressId);
|
||||
|
||||
Event::dispatch('customer.addresses.delete.after', $addressId);
|
||||
}
|
||||
|
||||
session()->flash('success', trans('admin::app.customers.addresses.success-mass-delete'));
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@
|
|||
|
||||
namespace Webkul\Admin\Http\Controllers\Customer;
|
||||
|
||||
use Mail;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Webkul\Admin\DataGrids\CustomerDataGrid;
|
||||
use Webkul\Admin\DataGrids\CustomerOrderDataGrid;
|
||||
use Webkul\Admin\DataGrids\CustomersInvoicesDataGrid;
|
||||
|
|
@ -77,11 +78,15 @@ class CustomerController extends Controller
|
|||
|
||||
$password = rand(100000, 10000000);
|
||||
|
||||
Event::dispatch('customer.registration.before');
|
||||
|
||||
$customer = $this->customerRepository->create(array_merge(request()->all() , [
|
||||
'password' => bcrypt($password),
|
||||
'is_verified' => 1,
|
||||
]));
|
||||
|
||||
Event::dispatch('customer.registration.after', $customer);
|
||||
|
||||
try {
|
||||
$configKey = 'emails.general.notifications.emails.general.notifications.customer';
|
||||
|
||||
|
|
@ -128,11 +133,15 @@ class CustomerController extends Controller
|
|||
'date_of_birth' => 'date|before:today',
|
||||
]);
|
||||
|
||||
$this->customerRepository->update(array_merge(request()->all(), [
|
||||
'status' => isset($data['status']),
|
||||
'is_suspended' => isset($data['is_suspended']),
|
||||
Event::dispatch('customer.update.before', $id);
|
||||
|
||||
$customer = $this->customerRepository->update(array_merge(request()->all(), [
|
||||
'status' => request()->has('status'),
|
||||
'is_suspended' => request()->has('is_suspended'),
|
||||
]), $id);
|
||||
|
||||
Event::dispatch('customer.update.after', $customer);
|
||||
|
||||
session()->flash('success', trans('admin::app.response.update-success', ['name' => 'Customer']));
|
||||
|
||||
return redirect()->route($this->_config['redirect']);
|
||||
|
|
@ -185,9 +194,13 @@ class CustomerController extends Controller
|
|||
'notes' => 'string|nullable',
|
||||
]);
|
||||
|
||||
$customer = $this->customerRepository->find(request()->input('_customer'));
|
||||
Event::dispatch('customer.update.before', request()->input('_customer'));
|
||||
|
||||
$noteTaken = $customer->update(['notes' => request()->input('notes')]);
|
||||
$customer = $this->customerRepository->update([
|
||||
'notes' => request()->input('notes'),
|
||||
], request()->input('_customer'));
|
||||
|
||||
Event::dispatch('customer.update.after', $customer);
|
||||
|
||||
session()->flash('success', 'Note taken');
|
||||
|
||||
|
|
@ -206,9 +219,13 @@ class CustomerController extends Controller
|
|||
$updateOption = request()->input('update-options');
|
||||
|
||||
foreach ($customerIds as $customerId) {
|
||||
$customer = $this->customerRepository->find($customerId);
|
||||
Event::dispatch('customer.update.before', $customerId);
|
||||
|
||||
$customer->update(['status' => $updateOption]);
|
||||
$customer = $this->customerRepository->update([
|
||||
'status' => $updateOption,
|
||||
], $customerId);
|
||||
|
||||
Event::dispatch('customer.update.after', $customer);
|
||||
}
|
||||
|
||||
session()->flash('success', trans('admin::app.customers.customers.mass-update-success'));
|
||||
|
|
@ -226,9 +243,12 @@ class CustomerController extends Controller
|
|||
$customerIds = explode(',', request()->input('indexes'));
|
||||
|
||||
if (! $this->customerRepository->checkBulkCustomerIfTheyHaveOrderPendingOrProcessing($customerIds)) {
|
||||
|
||||
foreach ($customerIds as $customerId) {
|
||||
$this->customerRepository->deleteWhere(['id' => $customerId]);
|
||||
Event::dispatch('customer.delete.before', $customerId);
|
||||
|
||||
$this->customerRepository->delete($customerId);
|
||||
|
||||
Event::dispatch('customer.delete.after', $customerId);
|
||||
}
|
||||
|
||||
session()->flash('success', trans('admin::app.customers.customers.mass-destroy-success'));
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Webkul\Admin\Http\Controllers\Customer;
|
||||
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Webkul\Admin\DataGrids\CustomerGroupDataGrid;
|
||||
use Webkul\Admin\Http\Controllers\Controller;
|
||||
use Webkul\Customer\Repositories\CustomerGroupRepository;
|
||||
|
|
@ -62,10 +63,14 @@ class CustomerGroupController extends Controller
|
|||
'name' => 'required',
|
||||
]);
|
||||
|
||||
$this->customerGroupRepository->create(array_merge(request()->all() , [
|
||||
Event::dispatch('customer.customer_group.create.before');
|
||||
|
||||
$customerGroup = $this->customerGroupRepository->create(array_merge(request()->all() , [
|
||||
'is_user_defined' => 1,
|
||||
]));
|
||||
|
||||
Event::dispatch('customer.customer_group.create.after', $customerGroup);
|
||||
|
||||
session()->flash('success', trans('admin::app.response.create-success', ['name' => 'Customer Group']));
|
||||
|
||||
return redirect()->route($this->_config['redirect']);
|
||||
|
|
@ -97,7 +102,11 @@ class CustomerGroupController extends Controller
|
|||
'name' => 'required',
|
||||
]);
|
||||
|
||||
$this->customerGroupRepository->update(request()->all(), $id);
|
||||
Event::dispatch('customer.customer_group.update.before', $id);
|
||||
|
||||
$customerGroup = $this->customerGroupRepository->update(request()->all(), $id);
|
||||
|
||||
Event::dispatch('customer.customer_group.update.after', $customerGroup);
|
||||
|
||||
session()->flash('success', trans('admin::app.response.update-success', ['name' => 'Customer Group']));
|
||||
|
||||
|
|
@ -127,8 +136,12 @@ class CustomerGroupController extends Controller
|
|||
}
|
||||
|
||||
try {
|
||||
Event::dispatch('customer.customer_group.delete.before', $id);
|
||||
|
||||
$this->customerGroupRepository->delete($id);
|
||||
|
||||
Event::dispatch('customer.customer_group.delete.after', $id);
|
||||
|
||||
return response()->json(['message' => trans('admin::app.response.delete-success', ['name' => 'Customer Group'])]);
|
||||
} catch (\Exception $e) {}
|
||||
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ class OrderController extends Controller
|
|||
|
||||
$comment = $this->orderCommentRepository->create(array_merge(request()->all(), [
|
||||
'order_id' => $id,
|
||||
'customer_notified' => isset($data['customer_notified']),
|
||||
'customer_notified' => request()->has('customer_notified'),
|
||||
]));
|
||||
|
||||
Event::dispatch('sales.order.comment.create.after', $comment);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Webkul\Attribute\Http\Controllers;
|
||||
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Webkul\Admin\DataGrids\AttributeDataGrid;
|
||||
use Webkul\Attribute\Repositories\AttributeRepository;
|
||||
|
||||
|
|
@ -62,10 +63,14 @@ class AttributeController extends Controller
|
|||
'type' => 'required',
|
||||
]);
|
||||
|
||||
$this->attributeRepository->create(array_merge(request()->all(), [
|
||||
Event::dispatch('catalog.attribute.create.before');
|
||||
|
||||
$attribute = $this->attributeRepository->create(array_merge(request()->all(), [
|
||||
'is_user_defined' => 1,
|
||||
]));
|
||||
|
||||
Event::dispatch('catalog.attribute.create.after', $attribute);
|
||||
|
||||
session()->flash('success', trans('admin::app.response.create-success', ['name' => 'Attribute']));
|
||||
|
||||
return redirect()->route($this->_config['redirect']);
|
||||
|
|
@ -111,7 +116,11 @@ class AttributeController extends Controller
|
|||
'type' => 'required',
|
||||
]);
|
||||
|
||||
$this->attributeRepository->update(request()->all(), $id);
|
||||
Event::dispatch('catalog.attribute.update.before', $id);
|
||||
|
||||
$attribute = $this->attributeRepository->update(request()->all(), $id);
|
||||
|
||||
Event::dispatch('catalog.attribute.update.after', $attribute);
|
||||
|
||||
session()->flash('success', trans('admin::app.response.update-success', ['name' => 'Attribute']));
|
||||
|
||||
|
|
@ -135,8 +144,12 @@ class AttributeController extends Controller
|
|||
}
|
||||
|
||||
try {
|
||||
Event::dispatch('catalog.attribute.delete.before', $id);
|
||||
|
||||
$this->attributeRepository->delete($id);
|
||||
|
||||
Event::dispatch('catalog.attribute.delete.after', $id);
|
||||
|
||||
return response()->json(['message' => trans('admin::app.response.delete-success', ['name' => 'Attribute'])]);
|
||||
} catch (\Exception $e) {}
|
||||
|
||||
|
|
@ -164,7 +177,11 @@ class AttributeController extends Controller
|
|||
}
|
||||
|
||||
foreach ($indexes as $index) {
|
||||
Event::dispatch('catalog.attribute.delete.before', $index);
|
||||
|
||||
$this->attributeRepository->delete($index);
|
||||
|
||||
Event::dispatch('catalog.attribute.delete.after', $index);
|
||||
}
|
||||
|
||||
session()->flash('success', trans('admin::app.datagrid.mass-ops.delete-success', ['resource' => 'attributes']));
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Webkul\Attribute\Http\Controllers;
|
||||
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Webkul\Admin\DataGrids\AttributeFamilyDataGrid;
|
||||
use Webkul\Attribute\Repositories\AttributeFamilyRepository;
|
||||
use Webkul\Attribute\Repositories\AttributeRepository;
|
||||
|
|
@ -70,8 +71,12 @@ class AttributeFamilyController extends Controller
|
|||
'name' => 'required',
|
||||
]);
|
||||
|
||||
Event::dispatch('catalog.attribute_family.create.before');
|
||||
|
||||
$attributeFamily = $this->attributeFamilyRepository->create(request()->all());
|
||||
|
||||
Event::dispatch('catalog.attribute_family.create.after', $attributeFamily);
|
||||
|
||||
session()->flash('success', trans('admin::app.response.create-success', ['name' => 'Family']));
|
||||
|
||||
return redirect()->route($this->_config['redirect']);
|
||||
|
|
@ -105,8 +110,12 @@ class AttributeFamilyController extends Controller
|
|||
'name' => 'required',
|
||||
]);
|
||||
|
||||
Event::dispatch('catalog.attribute_family.update.before', $id);
|
||||
|
||||
$attributeFamily = $this->attributeFamilyRepository->update(request()->all(), $id);
|
||||
|
||||
Event::dispatch('catalog.attribute_family.update.after', $attributeFamily);
|
||||
|
||||
session()->flash('success', trans('admin::app.response.update-success', ['name' => 'Family']));
|
||||
|
||||
return redirect()->route($this->_config['redirect']);
|
||||
|
|
@ -135,8 +144,12 @@ class AttributeFamilyController extends Controller
|
|||
}
|
||||
|
||||
try {
|
||||
Event::dispatch('catalog.attribute_family.delete.before', $id);
|
||||
|
||||
$this->attributeFamilyRepository->delete($id);
|
||||
|
||||
Event::dispatch('catalog.attribute_family.delete.after', $id);
|
||||
|
||||
return response()->json([
|
||||
'message' => trans('admin::app.response.delete-success', ['name' => 'Family']),
|
||||
]);
|
||||
|
|
@ -161,9 +174,13 @@ class AttributeFamilyController extends Controller
|
|||
if (request()->isMethod('delete')) {
|
||||
$indexes = explode(',', request()->input('indexes'));
|
||||
|
||||
foreach ($indexes as $key => $value) {
|
||||
foreach ($indexes as $index) {
|
||||
try {
|
||||
$this->attributeFamilyRepository->delete($value);
|
||||
Event::dispatch('catalog.attribute_family.delete.before', $index);
|
||||
|
||||
$this->attributeFamilyRepository->delete($index);
|
||||
|
||||
Event::dispatch('catalog.attribute_family.delete.after', $index);
|
||||
} catch (\Exception $e) {
|
||||
report($e);
|
||||
$suppressFlash = true;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
namespace Webkul\Attribute\Repositories;
|
||||
|
||||
use Illuminate\Container\Container;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Support\Str;
|
||||
use Webkul\Core\Eloquent\Repository;
|
||||
use Webkul\Attribute\Repositories\AttributeRepository;
|
||||
|
|
@ -44,8 +43,6 @@ class AttributeFamilyRepository extends Repository
|
|||
*/
|
||||
public function create(array $data)
|
||||
{
|
||||
Event::dispatch('catalog.attribute_family.create.before');
|
||||
|
||||
$attributeGroups = isset($data['attribute_groups']) ? $data['attribute_groups'] : [];
|
||||
|
||||
unset($data['attribute_groups']);
|
||||
|
|
@ -70,8 +67,6 @@ class AttributeFamilyRepository extends Repository
|
|||
}
|
||||
}
|
||||
|
||||
Event::dispatch('catalog.attribute_family.create.after', $family);
|
||||
|
||||
return $family;
|
||||
}
|
||||
|
||||
|
|
@ -84,9 +79,7 @@ class AttributeFamilyRepository extends Repository
|
|||
public function update(array $data, $id, $attribute = "id")
|
||||
{
|
||||
$family = $this->find($id);
|
||||
|
||||
Event::dispatch('catalog.attribute_family.update.before', $id);
|
||||
|
||||
|
||||
$family->update($data);
|
||||
|
||||
$previousAttributeGroupIds = $family->attribute_groups()->pluck('id');
|
||||
|
|
@ -137,8 +130,6 @@ class AttributeFamilyRepository extends Repository
|
|||
$this->attributeGroupRepository->delete($attributeGroupId);
|
||||
}
|
||||
|
||||
Event::dispatch('catalog.attribute_family.update.after', $family);
|
||||
|
||||
return $family;
|
||||
}
|
||||
|
||||
|
|
@ -167,17 +158,4 @@ class AttributeFamilyRepository extends Repository
|
|||
|
||||
return $trimmed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @return void
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
Event::dispatch('catalog.attribute_family.delete.before', $id);
|
||||
|
||||
parent::delete($id);
|
||||
|
||||
Event::dispatch('catalog.attribute_family.delete.after', $id);
|
||||
}
|
||||
}
|
||||
|
|
@ -3,7 +3,6 @@
|
|||
namespace Webkul\Attribute\Repositories;
|
||||
|
||||
use Illuminate\Container\Container;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Webkul\Attribute\Repositories\AttributeOptionRepository;
|
||||
use Webkul\Core\Eloquent\Repository;
|
||||
|
||||
|
|
@ -42,8 +41,6 @@ class AttributeRepository extends Repository
|
|||
*/
|
||||
public function create(array $data)
|
||||
{
|
||||
Event::dispatch('catalog.attribute.create.before');
|
||||
|
||||
$data = $this->validateUserInput($data);
|
||||
|
||||
$options = isset($data['options']) ? $data['options'] : [];
|
||||
|
|
@ -63,8 +60,6 @@ class AttributeRepository extends Repository
|
|||
}
|
||||
}
|
||||
|
||||
Event::dispatch('catalog.attribute.create.after', $attribute);
|
||||
|
||||
return $attribute;
|
||||
}
|
||||
|
||||
|
|
@ -82,23 +77,21 @@ class AttributeRepository extends Repository
|
|||
|
||||
$attribute = $this->find($id);
|
||||
|
||||
Event::dispatch('catalog.attribute.update.before', $id);
|
||||
|
||||
$data['enable_wysiwyg'] = ! isset($data['enable_wysiwyg']) ? 0 : 1;
|
||||
$data['enable_wysiwyg'] = isset($data['enable_wysiwyg']);
|
||||
|
||||
$attribute->update($data);
|
||||
|
||||
if (in_array($attribute->type, ['select', 'multiselect', 'checkbox'])) {
|
||||
if (isset($data['options'])) {
|
||||
foreach ($data['options'] as $optionId => $optionInputs) {
|
||||
$isNew = $optionInputs['isNew'] == 'true' ? true : false;
|
||||
$isNew = $optionInputs['isNew'] == 'true';
|
||||
|
||||
if ($isNew) {
|
||||
$this->attributeOptionRepository->create(array_merge([
|
||||
'attribute_id' => $attribute->id,
|
||||
], $optionInputs));
|
||||
} else {
|
||||
$isDelete = $optionInputs['isDelete'] == 'true' ? true : false;
|
||||
$isDelete = $optionInputs['isDelete'] == 'true';
|
||||
|
||||
if ($isDelete) {
|
||||
$this->attributeOptionRepository->delete($optionId);
|
||||
|
|
@ -110,26 +103,9 @@ class AttributeRepository extends Repository
|
|||
}
|
||||
}
|
||||
|
||||
Event::dispatch('catalog.attribute.update.after', $attribute);
|
||||
|
||||
return $attribute;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete attribute.
|
||||
*
|
||||
* @param int $id
|
||||
* @return void
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
Event::dispatch('catalog.attribute.delete.before', $id);
|
||||
|
||||
parent::delete($id);
|
||||
|
||||
Event::dispatch('catalog.attribute.delete.after', $id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate user input.
|
||||
*
|
||||
|
|
@ -267,12 +243,11 @@ class AttributeRepository extends Repository
|
|||
)
|
||||
) {
|
||||
array_push($trimmed, [
|
||||
'id' => $attribute->id,
|
||||
'name' => $attribute->admin_name,
|
||||
'type' => $attribute->type,
|
||||
'code' => $attribute->code,
|
||||
'has_options' => $attribute->options()->exists(),
|
||||
'options' => $attribute->options,
|
||||
'id' => $attribute->id,
|
||||
'name' => $attribute->admin_name,
|
||||
'type' => $attribute->type,
|
||||
'code' => $attribute->code,
|
||||
'options' => $attribute->options,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ class Booking
|
|||
|
||||
$bookingProductSlot = $this->typeRepositories[$bookingProduct->type]->findOneByField('booking_product_id', $bookingProduct->id);
|
||||
|
||||
$availabileDays = $this->getAvailableWeekDays($bookingProduct);
|
||||
$availableDays = $this->getAvailableWeekDays($bookingProduct);
|
||||
|
||||
foreach ($this->daysOfWeek as $index => $isOpen) {
|
||||
$slots = [];
|
||||
|
|
@ -106,7 +106,7 @@ class Booking
|
|||
|
||||
$slotsByDays[] = [
|
||||
'name' => trans($this->daysOfWeek[$index]),
|
||||
'slots' => isset($availabileDays[$index]) ? $this->conver24To12Hours($slots) : [],
|
||||
'slots' => isset($availableDays[$index]) ? $this->conver24To12Hours($slots) : [],
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -128,8 +128,8 @@ class Booking
|
|||
}
|
||||
|
||||
return count($slots)
|
||||
? implode(' | ', $slots)
|
||||
: '<span class="text-danger">' . trans('bookingproduct::app.shop.products.closed') . '</span>';
|
||||
? implode(' | ', $slots)
|
||||
: '<span class="text-danger">' . trans('bookingproduct::app.shop.products.closed') . '</span>';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -162,15 +162,16 @@ class Booking
|
|||
$currentTime = Carbon::now();
|
||||
|
||||
$availableFrom = ! $bookingProduct->available_from && $bookingProduct->available_from
|
||||
? Carbon::createFromTimeString($bookingProduct->available_from)
|
||||
: Carbon::createFromTimeString($currentTime->format('Y-m-d 00:00:00'));
|
||||
? Carbon::createFromTimeString($bookingProduct->available_from)
|
||||
: Carbon::createFromTimeString($currentTime->format('Y-m-d 00:00:00'));
|
||||
|
||||
$availableTo = ! $bookingProduct->available_from && $bookingProduct->available_to
|
||||
? Carbon::createFromTimeString($bookingProduct->available_to)
|
||||
: Carbon::createFromTimeString('2080-01-01 00:00:00');
|
||||
? Carbon::createFromTimeString($bookingProduct->available_to)
|
||||
: Carbon::createFromTimeString('2080-01-01 00:00:00');
|
||||
|
||||
for ($i = 0; $i < 7; $i++) {
|
||||
$date = clone $currentTime;
|
||||
|
||||
$date->addDays($i);
|
||||
|
||||
if (
|
||||
|
|
@ -250,16 +251,16 @@ class Booking
|
|||
$requestedDate = Carbon::createFromTimeString($date . " 00:00:00");
|
||||
|
||||
$availableFrom = ! $bookingProduct->available_every_week && $bookingProduct->available_from
|
||||
? Carbon::createFromTimeString($bookingProduct->available_from)
|
||||
: Carbon::createFromTimeString($currentTime->format('Y-m-d 00:00:00'));
|
||||
? Carbon::createFromTimeString($bookingProduct->available_from)
|
||||
: Carbon::createFromTimeString($currentTime->format('Y-m-d 00:00:00'));
|
||||
|
||||
$availableTo = ! $bookingProduct->available_every_week && $bookingProduct->available_from
|
||||
? Carbon::createFromTimeString($bookingProduct->available_to)
|
||||
: Carbon::createFromTimeString('2080-01-01 00:00:00');
|
||||
? Carbon::createFromTimeString($bookingProduct->available_to)
|
||||
: Carbon::createFromTimeString('2080-01-01 00:00:00');
|
||||
|
||||
$timeDurations = $bookingProductSlot->same_slot_all_days
|
||||
? $bookingProductSlot->slots
|
||||
: ($bookingProductSlot->slots[$requestedDate->format('w')] ?? []);
|
||||
? $bookingProductSlot->slots
|
||||
: ($bookingProductSlot->slots[$requestedDate->format('w')] ?? []);
|
||||
|
||||
if (
|
||||
$requestedDate < $availableFrom
|
||||
|
|
@ -387,7 +388,7 @@ class Booking
|
|||
return $slot['timestamp'] == $cartItem['additional']['booking']['slot'];
|
||||
});
|
||||
|
||||
return count($filtered) ? false : true;
|
||||
return ! count($filtered);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -399,12 +400,12 @@ class Booking
|
|||
$timestamps = explode('-', $data['additional']['booking']['slot']);
|
||||
|
||||
$result = $this->bookingRepository->getModel()
|
||||
->leftJoin('order_items', 'bookings.order_item_id', '=', 'order_items.id')
|
||||
->addSelect(DB::raw('SUM(qty_ordered - qty_canceled - qty_refunded) as total_qty_booked'))
|
||||
->where('bookings.product_id', $data['product_id'])
|
||||
->where('bookings.from', $timestamps[0])
|
||||
->where('bookings.to', $timestamps[1])
|
||||
->first();
|
||||
->leftJoin('order_items', 'bookings.order_item_id', '=', 'order_items.id')
|
||||
->addSelect(DB::raw('SUM(qty_ordered - qty_canceled - qty_refunded) as total_qty_booked'))
|
||||
->where('bookings.product_id', $data['product_id'])
|
||||
->where('bookings.from', $timestamps[0])
|
||||
->where('bookings.to', $timestamps[1])
|
||||
->first();
|
||||
|
||||
return ! is_null($result->total_qty_booked) ? $result->total_qty_booked : 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,12 +34,12 @@ class DefaultSlot extends Booking
|
|||
$currentTime = Carbon::now();
|
||||
|
||||
$availableFrom = $bookingProduct->available_from
|
||||
? Carbon::createFromTimeString($bookingProduct->available_from)
|
||||
: Carbon::createFromTimeString($currentTime->format('Y-m-d 00:00:00'));
|
||||
? Carbon::createFromTimeString($bookingProduct->available_from)
|
||||
: Carbon::createFromTimeString($currentTime->format('Y-m-d 00:00:00'));
|
||||
|
||||
$availableTo = $bookingProduct->available_to
|
||||
? Carbon::createFromTimeString($bookingProduct->available_to)
|
||||
: Carbon::createFromTimeString('2080-01-01 00:00:00');
|
||||
? Carbon::createFromTimeString($bookingProduct->available_to)
|
||||
: Carbon::createFromTimeString('2080-01-01 00:00:00');
|
||||
|
||||
if (
|
||||
$requestedDate < $availableFrom
|
||||
|
|
@ -51,8 +51,8 @@ class DefaultSlot extends Booking
|
|||
$slots = [];
|
||||
|
||||
return $bookingProductSlot->booking_type == 'one'
|
||||
? $this->getOneBookingForManyDaysSlots($bookingProductSlot, $requestedDate)
|
||||
: $this->getManyBookingsforOneDaySlots($bookingProductSlot, $requestedDate);
|
||||
? $this->getOneBookingForManyDaysSlots($bookingProductSlot, $requestedDate)
|
||||
: $this->getManyBookingsforOneDaySlots($bookingProductSlot, $requestedDate);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -105,12 +105,12 @@ class DefaultSlot extends Booking
|
|||
$currentTime = Carbon::now();
|
||||
|
||||
$availableFrom = $bookingProduct->available_from
|
||||
? Carbon::createFromTimeString($bookingProduct->available_from)
|
||||
: Carbon::createFromTimeString($currentTime->format('Y-m-d 00:00:00'));
|
||||
? Carbon::createFromTimeString($bookingProduct->available_from)
|
||||
: Carbon::createFromTimeString($currentTime->format('Y-m-d 00:00:00'));
|
||||
|
||||
$availableTo = $bookingProduct->available_to
|
||||
? Carbon::createFromTimeString($bookingProduct->available_to)
|
||||
: Carbon::createFromTimeString('2080-01-01 00:00:00');
|
||||
? Carbon::createFromTimeString($bookingProduct->available_to)
|
||||
: Carbon::createFromTimeString('2080-01-01 00:00:00');
|
||||
|
||||
$timeDuration = $bookingProductSlot->slots[$requestedDate->format('w')] ?? [];
|
||||
|
||||
|
|
|
|||
|
|
@ -91,11 +91,11 @@ class EventTicket extends Booking
|
|||
public function getBookedQuantity($data)
|
||||
{
|
||||
$result = $this->bookingRepository->getModel()
|
||||
->leftJoin('order_items', 'bookings.order_item_id', '=', 'order_items.id')
|
||||
->addSelect(DB::raw('SUM(qty_ordered - qty_canceled - qty_refunded) as total_qty_booked'))
|
||||
->where('bookings.product_id', $data['product_id'])
|
||||
->where('bookings.booking_product_event_ticket_id', $data['additional']['booking']['ticket_id'])
|
||||
->first();
|
||||
->leftJoin('order_items', 'bookings.order_item_id', '=', 'order_items.id')
|
||||
->addSelect(DB::raw('SUM(qty_ordered - qty_canceled - qty_refunded) as total_qty_booked'))
|
||||
->where('bookings.product_id', $data['product_id'])
|
||||
->where('bookings.booking_product_event_ticket_id', $data['additional']['booking']['ticket_id'])
|
||||
->first();
|
||||
|
||||
return ! is_null($result->total_qty_booked) ? $result->total_qty_booked : 0;
|
||||
}
|
||||
|
|
@ -114,6 +114,7 @@ class EventTicket extends Booking
|
|||
$ticket = $bookingProduct->event_tickets()->find($product['additional']['booking']['ticket_id']);
|
||||
|
||||
$price = $ticket->price;
|
||||
|
||||
if ($this->isInSale($ticket)) {
|
||||
$price = $ticket->special_price;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,16 +33,16 @@ class RentalSlot extends Booking
|
|||
$currentTime = Carbon::now();
|
||||
|
||||
$availableFrom = ! $bookingProduct->available_every_week && $bookingProduct->available_from
|
||||
? Carbon::createFromTimeString($bookingProduct->available_from)
|
||||
: Carbon::createFromTimeString($currentTime->format('Y-m-d 00:00:00'));
|
||||
? Carbon::createFromTimeString($bookingProduct->available_from)
|
||||
: Carbon::createFromTimeString($currentTime->format('Y-m-d 00:00:00'));
|
||||
|
||||
$availableTo = ! $bookingProduct->available_every_week && $bookingProduct->available_from
|
||||
? Carbon::createFromTimeString($bookingProduct->available_to)
|
||||
: Carbon::createFromTimeString('2080-01-01 00:00:00');
|
||||
? Carbon::createFromTimeString($bookingProduct->available_to)
|
||||
: Carbon::createFromTimeString('2080-01-01 00:00:00');
|
||||
|
||||
$timeDurations = $bookingProductSlot->same_slot_all_days
|
||||
? $bookingProductSlot->slots
|
||||
: $bookingProductSlot->slots[$requestedDate->format('w')] ?? [];
|
||||
? $bookingProductSlot->slots
|
||||
: $bookingProductSlot->slots[$requestedDate->format('w')] ?? [];
|
||||
|
||||
if (
|
||||
$requestedDate < $availableFrom
|
||||
|
|
@ -139,18 +139,18 @@ class RentalSlot extends Booking
|
|||
}
|
||||
|
||||
$result = $this->bookingRepository->getModel()
|
||||
->leftJoin('order_items', 'bookings.order_item_id', '=', 'order_items.id')
|
||||
->addSelect(DB::raw('SUM(qty_ordered - qty_canceled - qty_refunded) as total_qty_booked'))
|
||||
->where('bookings.product_id', $data['product_id'])
|
||||
->where(function ($query) use($from, $to) {
|
||||
$query->where(function ($query) use($from) {
|
||||
$query->where('bookings.from', '<=', $from)->where('bookings.to', '>=', $from);
|
||||
})
|
||||
->orWhere(function($query) use($to) {
|
||||
$query->where('bookings.from', '<=', $to)->where('bookings.to', '>=', $to);
|
||||
});
|
||||
})
|
||||
->first();
|
||||
->leftJoin('order_items', 'bookings.order_item_id', '=', 'order_items.id')
|
||||
->addSelect(DB::raw('SUM(qty_ordered - qty_canceled - qty_refunded) as total_qty_booked'))
|
||||
->where('bookings.product_id', $data['product_id'])
|
||||
->where(function ($query) use($from, $to) {
|
||||
$query->where(function ($query) use($from) {
|
||||
$query->where('bookings.from', '<=', $from)->where('bookings.to', '>=', $from);
|
||||
})
|
||||
->orWhere(function($query) use($to) {
|
||||
$query->where('bookings.from', '<=', $to)->where('bookings.to', '>=', $to);
|
||||
});
|
||||
})
|
||||
->first();
|
||||
|
||||
return ! is_null($result->total_qty_booked) ? $result->total_qty_booked : 0;
|
||||
}
|
||||
|
|
@ -187,12 +187,12 @@ class RentalSlot extends Booking
|
|||
$requestedToDate = Carbon::createFromTimeString($cartItem['additional']['booking']['date_to'] . " 23:59:59");
|
||||
|
||||
$availableFrom = ! $bookingProduct->available_every_week && $bookingProduct->available_from
|
||||
? Carbon::createFromTimeString($bookingProduct->available_from->format('Y-m-d') . ' 00:00:00')
|
||||
: Carbon::createFromTimeString($currentTime->format('Y-m-d 00:00:00'));
|
||||
? Carbon::createFromTimeString($bookingProduct->available_from->format('Y-m-d') . ' 00:00:00')
|
||||
: Carbon::createFromTimeString($currentTime->format('Y-m-d 00:00:00'));
|
||||
|
||||
$availableTo = ! $bookingProduct->available_every_week && $bookingProduct->available_from
|
||||
? Carbon::createFromTimeString($bookingProduct->available_to->format('Y-m-d') . ' 23:59:59')
|
||||
: Carbon::createFromTimeString('2080-01-01 00:00:00');
|
||||
? Carbon::createFromTimeString($bookingProduct->available_to->format('Y-m-d') . ' 23:59:59')
|
||||
: Carbon::createFromTimeString('2080-01-01 00:00:00');
|
||||
|
||||
if (
|
||||
$requestedFromDate < $availableFrom
|
||||
|
|
|
|||
|
|
@ -45,12 +45,12 @@ class BookingController extends Controller
|
|||
{
|
||||
if (request('view_type')) {
|
||||
$startDate = request()->get('startDate')
|
||||
? Carbon::createFromTimeString(request()->get('startDate') . " 00:00:01")
|
||||
: Carbon::now()->startOfWeek()->format('Y-m-d H:i:s');
|
||||
? Carbon::createFromTimeString(request()->get('startDate') . " 00:00:01")
|
||||
: Carbon::now()->startOfWeek()->format('Y-m-d H:i:s');
|
||||
|
||||
$endDate = request()->get('endDate')
|
||||
? Carbon::createFromTimeString(request()->get('endDate') . " 23:59:59")
|
||||
: Carbon::now()->endOfWeek()->format('Y-m-d H:i:s');
|
||||
? Carbon::createFromTimeString(request()->get('endDate') . " 23:59:59")
|
||||
: Carbon::now()->endOfWeek()->format('Y-m-d H:i:s');
|
||||
|
||||
$bookings = $this->bookingRepository->getBookings([strtotime($startDate), strtotime($endDate)])
|
||||
->map(function ($booking) {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Webkul\BookingProduct\Repositories;
|
||||
|
||||
use Illuminate\Container\Container as App;
|
||||
use Illuminate\Container\Container;
|
||||
use Carbon\Carbon;
|
||||
use Webkul\Core\Eloquent\Repository;
|
||||
|
||||
|
|
@ -21,6 +21,7 @@ class BookingProductRepository extends Repository
|
|||
* @param \Webkul\BookingProduct\Repositories\BookingProductEventTicketRepository $bookingProductEventTicketRepository
|
||||
* @param \Webkul\BookingProduct\Repositories\BookingProductRentalSlotRepository $bookingProductRentalSlotRepository
|
||||
* @param \Webkul\BookingProduct\Repositories\BookingProductTableSlotRepository $bookingProductTableSlotRepository
|
||||
* @param \Illuminate\Container\Container $container
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
|
|
@ -29,10 +30,10 @@ class BookingProductRepository extends Repository
|
|||
BookingProductEventTicketRepository $bookingProductEventTicketRepository,
|
||||
BookingProductRentalSlotRepository $bookingProductRentalSlotRepository,
|
||||
BookingProductTableSlotRepository $bookingProductTableSlotRepository,
|
||||
App $app
|
||||
Container $container
|
||||
)
|
||||
{
|
||||
parent::__construct($app);
|
||||
parent::__construct($container);
|
||||
|
||||
$this->typeRepositories['default'] = $bookingProductDefaultSlotRepository;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Webkul\BookingProduct\Repositories;
|
||||
|
||||
use Illuminate\Container\Container as App;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Carbon\Carbon;
|
||||
use Webkul\Core\Eloquent\Repository;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Webkul\CMS\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Webkul\Admin\DataGrids\CMSPageDataGrid;
|
||||
use Webkul\CMS\Http\Controllers\Controller;
|
||||
use Webkul\CMS\Repositories\CmsRepository;
|
||||
|
|
@ -64,8 +65,12 @@ class PageController extends Controller
|
|||
'html_content' => 'required',
|
||||
]);
|
||||
|
||||
Event::dispatch('cms.pages.create.before');
|
||||
|
||||
$page = $this->cmsRepository->create(request()->all());
|
||||
|
||||
Event::dispatch('cms.pages.create.after', $page);
|
||||
|
||||
session()->flash('success', trans('admin::app.response.create-success', ['name' => 'page']));
|
||||
|
||||
return redirect()->route($this->_config['redirect']);
|
||||
|
|
@ -105,7 +110,11 @@ class PageController extends Controller
|
|||
'channels' => 'required',
|
||||
]);
|
||||
|
||||
$this->cmsRepository->update(request()->all(), $id);
|
||||
Event::dispatch('cms.pages.update.before', $id);
|
||||
|
||||
$page = $this->cmsRepository->update(request()->all(), $id);
|
||||
|
||||
Event::dispatch('cms.pages.update.after', $page);
|
||||
|
||||
session()->flash('success', trans('admin::app.response.update-success', ['name' => 'Page']));
|
||||
|
||||
|
|
@ -120,11 +129,15 @@ class PageController extends Controller
|
|||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
$page = $this->cmsRepository->findOrFail($id);
|
||||
try {
|
||||
Event::dispatch('cms.pages.delete.before', $id);
|
||||
|
||||
$this->cmsRepository->delete($id);
|
||||
|
||||
Event::dispatch('cms.pages.delete.after', $id);
|
||||
|
||||
if ($page->delete()) {
|
||||
return response()->json(['message' => trans('admin::app.cms.pages.delete-success')]);
|
||||
}
|
||||
} catch (\Exception $e) {}
|
||||
|
||||
return response()->json(['message' => trans('admin::app.cms.pages.delete-failure')], 500);
|
||||
}
|
||||
|
|
@ -136,32 +149,20 @@ class PageController extends Controller
|
|||
*/
|
||||
public function massDelete()
|
||||
{
|
||||
$data = request()->all();
|
||||
if (request()->isMethod('post')) {
|
||||
$indexes = explode(',', request()->input('indexes'));
|
||||
|
||||
if ($data['indexes']) {
|
||||
$pageIDs = explode(',', $data['indexes']);
|
||||
foreach ($indexes as $index) {
|
||||
Event::dispatch('cms.pages.delete.before', $index);
|
||||
|
||||
$count = 0;
|
||||
$this->cmsRepository->delete($index);
|
||||
|
||||
foreach ($pageIDs as $pageId) {
|
||||
$page = $this->cmsRepository->find($pageId);
|
||||
|
||||
if ($page) {
|
||||
$page->delete();
|
||||
|
||||
$count++;
|
||||
}
|
||||
Event::dispatch('cms.pages.delete.after', $index);
|
||||
}
|
||||
|
||||
if (count($pageIDs) == $count) {
|
||||
session()->flash('success', trans('admin::app.datagrid.mass-ops.delete-success', [
|
||||
'resource' => 'CMS Pages',
|
||||
]));
|
||||
} else {
|
||||
session()->flash('success', trans('admin::app.datagrid.mass-ops.partial-action', [
|
||||
'resource' => 'CMS Pages',
|
||||
]));
|
||||
}
|
||||
session()->flash('success', trans('admin::app.datagrid.mass-ops.delete-success', [
|
||||
'resource' => 'CMS Pages',
|
||||
]));
|
||||
} else {
|
||||
session()->flash('warning', trans('admin::app.datagrid.mass-ops.no-resource'));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Webkul\CMS\Repositories;
|
||||
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Webkul\Core\Eloquent\Repository;
|
||||
use Webkul\CMS\Models\CmsPageTranslationProxy;
|
||||
|
|
@ -25,8 +24,6 @@ class CmsRepository extends Repository
|
|||
*/
|
||||
public function create(array $data)
|
||||
{
|
||||
Event::dispatch('cms.pages.create.before');
|
||||
|
||||
$model = $this->getModel();
|
||||
|
||||
foreach (core()->getAllLocales() as $locale) {
|
||||
|
|
@ -43,8 +40,6 @@ class CmsRepository extends Repository
|
|||
|
||||
$page->channels()->sync($data['channels']);
|
||||
|
||||
Event::dispatch('cms.pages.create.after', $page);
|
||||
|
||||
return $page;
|
||||
}
|
||||
|
||||
|
|
@ -58,8 +53,6 @@ class CmsRepository extends Repository
|
|||
{
|
||||
$page = $this->find($id);
|
||||
|
||||
Event::dispatch('cms.pages.update.before', $id);
|
||||
|
||||
$locale = isset($data['locale']) ? $data['locale'] : app()->getLocale();
|
||||
|
||||
$data[$locale]['html_content'] = str_replace('=>', '=>', $data[$locale]['html_content']);
|
||||
|
|
@ -68,8 +61,6 @@ class CmsRepository extends Repository
|
|||
|
||||
$page->channels()->sync($data['channels']);
|
||||
|
||||
Event::dispatch('cms.pages.update.after', $id);
|
||||
|
||||
return $page;
|
||||
}
|
||||
|
||||
|
|
@ -88,7 +79,7 @@ class CmsRepository extends Repository
|
|||
->select(\DB::raw(1))
|
||||
->exists();
|
||||
|
||||
return $exists ? false : true;
|
||||
return ! $exists;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -3,8 +3,9 @@
|
|||
namespace Webkul\CartRule\Http\Controllers;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
use Webkul\Admin\DataGrids\CartRuleDataGrid;
|
||||
use Webkul\CartRule\Http\Requests\CartRuleRequest;
|
||||
|
|
@ -99,7 +100,11 @@ class CartRuleController extends Controller
|
|||
public function store(CartRuleRequest $cartRuleRequest)
|
||||
{
|
||||
try {
|
||||
$this->cartRuleRepository->create($cartRuleRequest->all());
|
||||
Event::dispatch('promotions.cart_rule.create.before');
|
||||
|
||||
$cartRule = $this->cartRuleRepository->create($cartRuleRequest->all());
|
||||
|
||||
Event::dispatch('promotions.cart_rule.create.after', $cartRule);
|
||||
|
||||
session()->flash('success', trans('admin::app.response.create-success', ['name' => 'Cart Rule']));
|
||||
|
||||
|
|
@ -150,8 +155,12 @@ class CartRuleController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
Event::dispatch('promotions.cart_rule.update.before', $id);
|
||||
|
||||
$cartRule = $this->cartRuleRepository->update($cartRuleRequest->all(), $id);
|
||||
|
||||
Event::dispatch('promotions.cart_rule.update.after', $cartRule);
|
||||
|
||||
session()->flash('success', trans('admin::app.response.update-success', ['name' => 'Cart Rule']));
|
||||
|
||||
return redirect()->route($this->_config['redirect']);
|
||||
|
|
@ -175,8 +184,12 @@ class CartRuleController extends Controller
|
|||
$this->cartRuleRepository->findOrFail($id);
|
||||
|
||||
try {
|
||||
Event::dispatch('promotions.cart_rule.delete.before', $id);
|
||||
|
||||
$this->cartRuleRepository->delete($id);
|
||||
|
||||
Event::dispatch('promotions.cart_rule.delete.after', $id);
|
||||
|
||||
return response()->json(['message' => trans('admin::app.response.delete-success', ['name' => 'Cart Rule'])]);
|
||||
} catch (Exception $e) {}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,7 @@
|
|||
|
||||
namespace Webkul\CartRule\Repositories;
|
||||
|
||||
use Illuminate\Container\Container as App;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Container\Container;
|
||||
use Webkul\Attribute\Repositories\AttributeFamilyRepository;
|
||||
use Webkul\Attribute\Repositories\AttributeRepository;
|
||||
use Webkul\Category\Repositories\CategoryRepository;
|
||||
|
|
@ -24,7 +23,7 @@ class CartRuleRepository extends Repository
|
|||
* @param \Webkul\Tax\Repositories\TaxCategoryRepository $taxCategoryRepository
|
||||
* @param \Webkul\Core\Repositories\CountryRepository $countryRepository
|
||||
* @param \Webkul\Core\Repositories\CountryStateRepository $countryStateRepository
|
||||
* @param \Illuminate\Container\Container $app
|
||||
* @param \Illuminate\Container\Container $container
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
|
|
@ -35,10 +34,10 @@ class CartRuleRepository extends Repository
|
|||
protected TaxCategoryRepository $taxCategoryRepository,
|
||||
protected CountryRepository $countryRepository,
|
||||
protected CountryStateRepository $countryStateRepository,
|
||||
App $app
|
||||
Container $container
|
||||
)
|
||||
{
|
||||
parent::__construct($app);
|
||||
parent::__construct($container);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -57,8 +56,6 @@ class CartRuleRepository extends Repository
|
|||
*/
|
||||
public function create(array $data)
|
||||
{
|
||||
Event::dispatch('promotions.cart_rule.create.before');
|
||||
|
||||
$data['starts_from'] = isset($data['starts_from']) && $data['starts_from'] ? $data['starts_from'] : null;
|
||||
|
||||
$data['ends_till'] = isset($data['ends_till']) && $data['ends_till'] ? $data['ends_till'] : null;
|
||||
|
|
@ -85,8 +82,6 @@ class CartRuleRepository extends Repository
|
|||
]);
|
||||
}
|
||||
|
||||
Event::dispatch('promotions.cart_rule.create.after', $cartRule);
|
||||
|
||||
return $cartRule;
|
||||
}
|
||||
|
||||
|
|
@ -98,7 +93,6 @@ class CartRuleRepository extends Repository
|
|||
*/
|
||||
public function update(array $data, $id, $attribute = 'id')
|
||||
{
|
||||
Event::dispatch('promotions.cart_rule.update.before', $id);
|
||||
|
||||
$data = array_merge($data, [
|
||||
'starts_from' => $data['starts_from'] ?: null,
|
||||
|
|
@ -141,7 +135,7 @@ class CartRuleRepository extends Repository
|
|||
}
|
||||
} else {
|
||||
$this->cartRuleCouponRepository->deleteWhere([
|
||||
'is_primary' => 1,
|
||||
'is_primary' => 1,
|
||||
'cart_rule_id' => $cartRule->id,
|
||||
]);
|
||||
|
||||
|
|
@ -155,26 +149,9 @@ class CartRuleRepository extends Repository
|
|||
$cartRuleCoupon = $this->cartRuleCouponRepository->deleteWhere(['is_primary' => 1, 'cart_rule_id' => $cartRule->id]);
|
||||
}
|
||||
|
||||
Event::dispatch('promotions.cart_rule.update.after', $cartRule);
|
||||
|
||||
return $cartRule;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete.
|
||||
*
|
||||
* @param $id
|
||||
* @return int
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
Event::dispatch('promotions.cart_rule.delete.before', $id);
|
||||
|
||||
parent::delete($id);
|
||||
|
||||
Event::dispatch('promotions.cart_rule.delete.after', $id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns attributes for cart rule conditions.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
namespace Webkul\CatalogRule\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Webkul\Admin\DataGrids\CatalogRuleDataGrid;
|
||||
use Webkul\CatalogRule\Helpers\CatalogRuleIndex;
|
||||
use Webkul\CatalogRule\Http\Requests\CatalogRuleRequest;
|
||||
|
|
@ -64,7 +65,11 @@ class CatalogRuleController extends Controller
|
|||
*/
|
||||
public function store(CatalogRuleRequest $catalogRuleRequest)
|
||||
{
|
||||
$this->catalogRuleRepository->create($catalogRuleRequest->all());
|
||||
Event::dispatch('promotions.catalog_rule.create.before');
|
||||
|
||||
$catalogRule = $this->catalogRuleRepository->create($catalogRuleRequest->all());
|
||||
|
||||
Event::dispatch('promotions.catalog_rule.create.after', $catalogRule);
|
||||
|
||||
$this->catalogRuleIndexHelper->reindexComplete();
|
||||
|
||||
|
|
@ -97,7 +102,11 @@ class CatalogRuleController extends Controller
|
|||
{
|
||||
$this->catalogRuleRepository->findOrFail($id);
|
||||
|
||||
$this->catalogRuleRepository->update($catalogRuleRequest->all(), $id);
|
||||
Event::dispatch('promotions.catalog_rule.update.before', $id);
|
||||
|
||||
$catalogRule = $this->catalogRuleRepository->update($catalogRuleRequest->all(), $id);
|
||||
|
||||
Event::dispatch('promotions.catalog_rule.update.after', $catalogRule);
|
||||
|
||||
$this->catalogRuleIndexHelper->reindexComplete();
|
||||
|
||||
|
|
@ -117,8 +126,12 @@ class CatalogRuleController extends Controller
|
|||
$this->catalogRuleRepository->findOrFail($id);
|
||||
|
||||
try {
|
||||
Event::dispatch('promotions.catalog_rule.delete.before', $id);
|
||||
|
||||
$this->catalogRuleRepository->delete($id);
|
||||
|
||||
Event::dispatch('promotions.catalog_rule.delete.after', $id);
|
||||
|
||||
return response()->json(['message' => trans('admin::app.response.delete-success', ['name' => 'Catalog Rule'])]);
|
||||
} catch (\Exception $e) {}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,7 @@
|
|||
|
||||
namespace Webkul\CatalogRule\Repositories;
|
||||
|
||||
use Illuminate\Container\Container as App;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Container\Container;
|
||||
use Webkul\Attribute\Repositories\AttributeFamilyRepository;
|
||||
use Webkul\Attribute\Repositories\AttributeRepository;
|
||||
use Webkul\Category\Repositories\CategoryRepository;
|
||||
|
|
@ -19,7 +18,7 @@ class CatalogRuleRepository extends Repository
|
|||
* @param \Webkul\Attribute\Repositories\AttributeRepository $attributeRepository
|
||||
* @param \Webkul\Category\Repositories\CategoryRepository $categoryRepository
|
||||
* @param \Webkul\Tax\Repositories\TaxCategoryRepository $taxCategoryRepository
|
||||
* @param \Illuminate\Container\Container $app
|
||||
* @param \Illuminate\Container\Container $container
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
|
|
@ -27,10 +26,10 @@ class CatalogRuleRepository extends Repository
|
|||
protected AttributeRepository $attributeRepository,
|
||||
protected CategoryRepository $categoryRepository,
|
||||
protected TaxCategoryRepository $taxCategoryRepository,
|
||||
App $app
|
||||
Container $container
|
||||
)
|
||||
{
|
||||
parent::__construct($app);
|
||||
parent::__construct($container);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -51,8 +50,6 @@ class CatalogRuleRepository extends Repository
|
|||
*/
|
||||
public function create(array $data)
|
||||
{
|
||||
Event::dispatch('promotions.catalog_rule.create.before');
|
||||
|
||||
$data = array_merge($data, [
|
||||
'starts_from' => $data['starts_from'] ?: null,
|
||||
'ends_till' => $data['ends_till'] ?: null,
|
||||
|
|
@ -65,8 +62,6 @@ class CatalogRuleRepository extends Repository
|
|||
|
||||
$catalogRule->customer_groups()->sync($data['customer_groups']);
|
||||
|
||||
Event::dispatch('promotions.catalog_rule.create.after', $catalogRule);
|
||||
|
||||
return $catalogRule;
|
||||
}
|
||||
|
||||
|
|
@ -80,7 +75,6 @@ class CatalogRuleRepository extends Repository
|
|||
*/
|
||||
public function update(array $data, $id, $attribute = 'id')
|
||||
{
|
||||
Event::dispatch('promotions.catalog_rule.update.before', $id);
|
||||
|
||||
$data = array_merge($data, [
|
||||
'starts_from' => $data['starts_from'] ?: null,
|
||||
|
|
@ -97,26 +91,9 @@ class CatalogRuleRepository extends Repository
|
|||
|
||||
$catalogRule->customer_groups()->sync($data['customer_groups']);
|
||||
|
||||
Event::dispatch('promotions.catalog_rule.update.after', $catalogRule);
|
||||
|
||||
return $catalogRule;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete.
|
||||
*
|
||||
* @param $id
|
||||
* @return int
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
Event::dispatch('promotions.catalog_rule.delete.before', $id);
|
||||
|
||||
parent::delete($id);
|
||||
|
||||
Event::dispatch('promotions.catalog_rule.delete.after', $id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns attributes for catalog rule conditions.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Webkul\Category\Http\Controllers;
|
||||
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Webkul\Admin\DataGrids\CategoryDataGrid;
|
||||
use Webkul\Admin\DataGrids\CategoryProductDataGrid;
|
||||
use Webkul\Attribute\Repositories\AttributeRepository;
|
||||
|
|
@ -69,7 +70,11 @@ class CategoryController extends Controller
|
|||
*/
|
||||
public function store(CategoryRequest $categoryRequest)
|
||||
{
|
||||
$this->categoryRepository->create($categoryRequest->all());
|
||||
Event::dispatch('catalog.category.create.before');
|
||||
|
||||
$category = $this->categoryRepository->create($categoryRequest->all());
|
||||
|
||||
Event::dispatch('catalog.category.create.after', $category);
|
||||
|
||||
session()->flash('success', trans('admin::app.response.create-success', ['name' => 'Category']));
|
||||
|
||||
|
|
@ -115,7 +120,11 @@ class CategoryController extends Controller
|
|||
*/
|
||||
public function update(CategoryRequest $categoryRequest, $id)
|
||||
{
|
||||
$this->categoryRepository->update($categoryRequest->all(), $id);
|
||||
Event::dispatch('catalog.category.update.before', $id);
|
||||
|
||||
$category = $this->categoryRepository->update($categoryRequest->all(), $id);
|
||||
|
||||
Event::dispatch('catalog.category.update.after', $category);
|
||||
|
||||
session()->flash('success', trans('admin::app.response.update-success', ['name' => 'Category']));
|
||||
|
||||
|
|
@ -137,8 +146,12 @@ class CategoryController extends Controller
|
|||
}
|
||||
|
||||
try {
|
||||
Event::dispatch('catalog.category.delete.before', $id);
|
||||
|
||||
$this->categoryRepository->delete($id);
|
||||
|
||||
Event::dispatch('catalog.category.delete.after', $id);
|
||||
|
||||
return response()->json(['message' => trans('admin::app.response.delete-success', ['name' => 'Category'])]);
|
||||
} catch (\Exception $e) {}
|
||||
|
||||
|
|
@ -168,7 +181,11 @@ class CategoryController extends Controller
|
|||
try {
|
||||
$suppressFlash = true;
|
||||
|
||||
Event::dispatch('catalog.category.delete.before', $categoryId);
|
||||
|
||||
$this->categoryRepository->delete($categoryId);
|
||||
|
||||
Event::dispatch('catalog.category.delete.after', $categoryId);
|
||||
} catch (\Exception $e) {
|
||||
session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Category']));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ namespace Webkul\Category\Repositories;
|
|||
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Webkul\Category\Models\CategoryTranslationProxy;
|
||||
use Webkul\Core\Eloquent\Repository;
|
||||
|
|
@ -29,8 +28,6 @@ class CategoryRepository extends Repository
|
|||
*/
|
||||
public function create(array $data)
|
||||
{
|
||||
Event::dispatch('catalog.category.create.before');
|
||||
|
||||
if (
|
||||
isset($data['locale'])
|
||||
&& $data['locale'] == 'all'
|
||||
|
|
@ -56,8 +53,6 @@ class CategoryRepository extends Repository
|
|||
$category->filterableAttributes()->sync($data['attributes']);
|
||||
}
|
||||
|
||||
Event::dispatch('catalog.category.create.after', $category);
|
||||
|
||||
return $category;
|
||||
}
|
||||
|
||||
|
|
@ -73,8 +68,6 @@ class CategoryRepository extends Repository
|
|||
{
|
||||
$category = $this->find($id);
|
||||
|
||||
Event::dispatch('catalog.category.update.before', $id);
|
||||
|
||||
$data = $this->setSameAttributeValueToAllLocale($data, 'slug');
|
||||
|
||||
$category->update($data);
|
||||
|
|
@ -85,26 +78,9 @@ class CategoryRepository extends Repository
|
|||
$category->filterableAttributes()->sync($data['attributes']);
|
||||
}
|
||||
|
||||
Event::dispatch('catalog.category.update.after', $id);
|
||||
|
||||
return $category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete category.
|
||||
*
|
||||
* @param int $id
|
||||
* @return void
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
Event::dispatch('catalog.category.delete.before', $id);
|
||||
|
||||
parent::delete($id);
|
||||
|
||||
Event::dispatch('catalog.category.delete.after', $id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify category tree.
|
||||
*
|
||||
|
|
@ -175,7 +151,7 @@ class CategoryRepository extends Repository
|
|||
->select(DB::raw(1))
|
||||
->exists();
|
||||
|
||||
return $exists ? false : true;
|
||||
return ! $exists;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ class Cart
|
|||
{
|
||||
use CartCoupons, CartTools, CartValidators;
|
||||
|
||||
|
||||
/**
|
||||
* @var \Webkul\Checkout\Contracts\Cart
|
||||
*/
|
||||
|
|
@ -34,12 +33,12 @@ class Cart
|
|||
/**
|
||||
* Create a new class instance.
|
||||
*
|
||||
* @param \Webkul\Checkout\Repositories\CartRepository $cartRepository
|
||||
* @param \Webkul\Checkout\Repositories\CartItemRepository $cartItemRepository
|
||||
* @param \Webkul\Checkout\Repositories\CartAddressRepository $cartAddressRepository
|
||||
* @param \Webkul\Product\Repositories\ProductRepository $productRepository
|
||||
* @param \Webkul\Tax\Repositories\TaxCategoryRepository $taxCategoryRepository
|
||||
* @param \Webkul\Customer\Repositories\WishlistRepository $wishlistRepository
|
||||
* @param \Webkul\Checkout\Repositories\CartRepository $cartRepository
|
||||
* @param \Webkul\Checkout\Repositories\CartItemRepository $cartItemRepository
|
||||
* @param \Webkul\Checkout\Repositories\CartAddressRepository $cartAddressRepository
|
||||
* @param \Webkul\Product\Repositories\ProductRepository $productRepository
|
||||
* @param \Webkul\Tax\Repositories\TaxCategoryRepository $taxCategoryRepository
|
||||
* @param \Webkul\Customer\Repositories\WishlistRepository $wishlistRepository
|
||||
* @param \Webkul\Customer\Repositories\CustomerAddressRepository $customerAddressRepository
|
||||
* @return void
|
||||
*/
|
||||
|
|
@ -127,11 +126,11 @@ class Cart
|
|||
|
||||
foreach ($items as $item) {
|
||||
if ($item->product->getTypeInstance()->compareOptions($item->additional, $data['additional'])) {
|
||||
if (isset($data['additional']['parent_id'])) {
|
||||
if ($item->parent->product->getTypeInstance()->compareOptions($item->parent->additional, $parentData ?: request()->all())) {
|
||||
return $item;
|
||||
}
|
||||
} else {
|
||||
if (! isset($data['additional']['parent_id'])) {
|
||||
return $item;
|
||||
}
|
||||
|
||||
if ($item->parent->product->getTypeInstance()->compareOptions($item->parent->additional, $parentData ?: request()->all())) {
|
||||
return $item;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,8 @@ trait CartValidators
|
|||
{
|
||||
if (
|
||||
! $this->getCart()
|
||||
|| ! $this->isItemsHaveSufficientQuantity()) {
|
||||
|| ! $this->isItemsHaveSufficientQuantity()
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ namespace Webkul\Core\Eloquent;
|
|||
use Prettus\Repository\Contracts\CacheableInterface;
|
||||
use Prettus\Repository\Eloquent\BaseRepository;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Container\Container as App;
|
||||
use Prettus\Repository\Traits\CacheableRepository;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ class Handler extends AppExceptionHandler
|
|||
*/
|
||||
private function isAdminUri()
|
||||
{
|
||||
return strpos(\Illuminate\Support\Facades\Request::path(), 'admin') !== false ? true : false;
|
||||
return strpos(\Illuminate\Support\Facades\Request::path(), 'admin') !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -50,9 +50,9 @@ class CoreConfigRepository extends Repository
|
|||
foreach ($recurssiveData as $fieldName => $value) {
|
||||
$field = core()->getConfigField($fieldName);
|
||||
|
||||
$channelBased = isset($field['channel_based']) && $field['channel_based'] ? true : false;
|
||||
$channelBased = isset($field['channel_based']) && $field['channel_based'];
|
||||
|
||||
$localeBased = isset($field['locale_based']) && $field['locale_based'] ? true : false;
|
||||
$localeBased = isset($field['locale_based']) && $field['locale_based'];
|
||||
|
||||
if (
|
||||
getType($value) == 'array'
|
||||
|
|
|
|||
|
|
@ -2,13 +2,13 @@
|
|||
|
||||
namespace Webkul\Core\Repositories;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Arr;
|
||||
use Webkul\Core\Eloquent\Repository;
|
||||
use Illuminate\Container\Container;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Container\Container as App;
|
||||
use Illuminate\Support\Arr;
|
||||
use Prettus\Repository\Traits\CacheableRepository;
|
||||
use Carbon\Carbon;
|
||||
use Webkul\Core\Eloquent\Repository;
|
||||
|
||||
class SliderRepository extends Repository
|
||||
{
|
||||
|
|
@ -18,15 +18,15 @@ class SliderRepository extends Repository
|
|||
* Create a new repository instance.
|
||||
*
|
||||
* @param \Webkul\Core\Repositories\ChannelRepository $channelRepository
|
||||
* @param \Illuminate\Container\Container $channelRepository
|
||||
* @param \Illuminate\Container\Container $container
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
protected ChannelRepository $channelRepository,
|
||||
App $app
|
||||
Container $container
|
||||
)
|
||||
{
|
||||
parent::__construct($app);
|
||||
parent::__construct($container);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Webkul\Customer\Http\Controllers;
|
||||
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Webkul\Customer\Http\Requests\CustomerAddressRequest;
|
||||
use Webkul\Customer\Repositories\CustomerAddressRepository;
|
||||
|
||||
|
|
@ -65,24 +66,19 @@ class AddressController extends Controller
|
|||
{
|
||||
$customer = auth()->guard('customer')->user();
|
||||
|
||||
$data = $request->all();
|
||||
Event::dispatch('customer.addresses.create.before');
|
||||
|
||||
$data['customer_id'] = $customer->id;
|
||||
$data['address1'] = implode(PHP_EOL, array_filter(request()->input('address1')));
|
||||
$customerAddress = $this->customerAddressRepository->create(array_merge($request->all(), [
|
||||
'customer_id' => $customer->id,
|
||||
'address1' => implode(PHP_EOL, array_filter(request()->input('address1'))),
|
||||
'default_address' => ! $customer->addresses->count(),
|
||||
]));
|
||||
|
||||
if ($customer->addresses->count() == 0) {
|
||||
$data['default_address'] = 1;
|
||||
}
|
||||
Event::dispatch('customer.addresses.create.after', $customerAddress);
|
||||
|
||||
if ($this->customerAddressRepository->create($data)) {
|
||||
session()->flash('success', trans('shop::app.customer.account.address.create.success'));
|
||||
session()->flash('success', trans('shop::app.customer.account.address.create.success'));
|
||||
|
||||
return redirect()->route($this->_config['redirect']);
|
||||
}
|
||||
|
||||
session()->flash('error', trans('shop::app.customer.account.address.create.error'));
|
||||
|
||||
return redirect()->back();
|
||||
return redirect()->route($this->_config['redirect']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -118,20 +114,22 @@ class AddressController extends Controller
|
|||
{
|
||||
$customer = auth()->guard('customer')->user();
|
||||
|
||||
$data = $request->all();
|
||||
|
||||
$data['address1'] = implode(PHP_EOL, array_filter(request()->input('address1')));
|
||||
|
||||
$addresses = $customer->addresses;
|
||||
|
||||
foreach ($addresses as $address) {
|
||||
if ($id == $address->id) {
|
||||
session()->flash('success', trans('shop::app.customer.account.address.edit.success'));
|
||||
|
||||
$this->customerAddressRepository->update($data, $id);
|
||||
|
||||
return redirect()->route('customer.address.index');
|
||||
foreach ($customer->addresses as $address) {
|
||||
if ($id != $address->id) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Event::dispatch('customer.addresses.update.before', $id);
|
||||
|
||||
$customerAddress = $this->customerAddressRepository->update(array_merge($request->all(), [
|
||||
'address1' => implode(PHP_EOL, array_filter(request()->input('address1'))),
|
||||
]), $id);
|
||||
|
||||
Event::dispatch('customer.addresses.update.after', $customerAddress);
|
||||
|
||||
session()->flash('success', trans('shop::app.customer.account.address.edit.success'));
|
||||
|
||||
return redirect()->route('customer.address.index');
|
||||
}
|
||||
|
||||
session()->flash('warning', trans('shop::app.security-warning'));
|
||||
|
|
@ -181,8 +179,12 @@ class AddressController extends Controller
|
|||
abort(404);
|
||||
}
|
||||
|
||||
Event::dispatch('customer.addresses.delete.before', $id);
|
||||
|
||||
$this->customerAddressRepository->delete($id);
|
||||
|
||||
Event::dispatch('customer.addresses.delete.after', $id);
|
||||
|
||||
session()->flash('success', trans('shop::app.customer.account.address.delete.success'));
|
||||
|
||||
return redirect()->route('customer.address.index');
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ class CustomerController extends Controller
|
|||
$data['image']['image_0'] = '';
|
||||
}
|
||||
|
||||
$data['subscribed_to_news_letter'] = isset($data['subscribed_to_news_letter']) ? 1 : 0;
|
||||
$data['subscribed_to_news_letter'] = isset($data['subscribed_to_news_letter']);
|
||||
|
||||
if (isset($data['oldpassword'])) {
|
||||
if (
|
||||
|
|
|
|||
|
|
@ -63,10 +63,10 @@ class RegistrationController extends Controller
|
|||
$data = array_merge(request()->input(), [
|
||||
'password' => bcrypt(request()->input('password')),
|
||||
'api_token' => Str::random(80),
|
||||
'is_verified' => core()->getConfigData('customer.settings.email.verification') ? 0 : 1,
|
||||
'is_verified' => (bool) core()->getConfigData('customer.settings.email.verification'),
|
||||
'customer_group_id' => $this->customerGroupRepository->findOneWhere(['code' => 'general'])->id,
|
||||
'token' => md5(uniqid(rand(), true)),
|
||||
'subscribed_to_news_letter' => isset(request()->input()['is_subscribed']) ? 1 : 0,
|
||||
'subscribed_to_news_letter' => isset(request()->input()['is_subscribed']),
|
||||
]);
|
||||
|
||||
Event::dispatch('customer.registration.before');
|
||||
|
|
|
|||
|
|
@ -92,12 +92,6 @@ class WishlistController extends Controller
|
|||
if (! $wishlist) {
|
||||
$wishlist = $this->wishlistRepository->create($data);
|
||||
|
||||
if ($wishlist) {
|
||||
session()->flash('success', trans('customer::app.wishlist.success'));
|
||||
} else {
|
||||
session()->flash('error', trans('customer::app.wishlist.failure'));
|
||||
}
|
||||
|
||||
return redirect()->back();
|
||||
} else {
|
||||
$this->wishlistRepository->findOneWhere([
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
namespace Webkul\Customer\Repositories;
|
||||
|
||||
use Webkul\Core\Eloquent\Repository;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
|
||||
class CustomerAddressRepository extends Repository
|
||||
{
|
||||
|
|
@ -23,9 +22,7 @@ class CustomerAddressRepository extends Repository
|
|||
*/
|
||||
public function create(array $data)
|
||||
{
|
||||
Event::dispatch('customer.addresses.create.before');
|
||||
|
||||
$data['default_address'] = isset($data['default_address']) ? 1 : 0;
|
||||
$data['default_address'] = isset($data['default_address']);
|
||||
|
||||
$default_address = $this
|
||||
->findWhere(['customer_id' => $data['customer_id'], 'default_address' => 1])
|
||||
|
|
@ -40,8 +37,6 @@ class CustomerAddressRepository extends Repository
|
|||
|
||||
$address = $this->model->create($data);
|
||||
|
||||
Event::dispatch('customer.addresses.create.after', $address);
|
||||
|
||||
return $address;
|
||||
}
|
||||
|
||||
|
|
@ -54,9 +49,7 @@ class CustomerAddressRepository extends Repository
|
|||
{
|
||||
$address = $this->find($id);
|
||||
|
||||
Event::dispatch('customer.addresses.update.before', $id);
|
||||
|
||||
$data['default_address'] = isset($data['default_address']) ? 1 : 0;
|
||||
$data['default_address'] = isset($data['default_address']);
|
||||
|
||||
$default_address = $this
|
||||
->findWhere(['customer_id' => $address->customer_id, 'default_address' => 1])
|
||||
|
|
@ -75,8 +68,6 @@ class CustomerAddressRepository extends Repository
|
|||
$address->update($data);
|
||||
}
|
||||
|
||||
Event::dispatch('customer.addresses.update.after', $id);
|
||||
|
||||
return $address;
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Webkul\Customer\Repositories;
|
||||
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Webkul\Core\Eloquent\Repository;
|
||||
|
||||
class CustomerGroupRepository extends Repository
|
||||
|
|
@ -18,59 +17,6 @@ class CustomerGroupRepository extends Repository
|
|||
return \Webkul\Customer\Contracts\CustomerGroup::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create.
|
||||
*
|
||||
* @param array $data
|
||||
* @return \Webkul\Customer\Contracts\CustomerGroup
|
||||
*/
|
||||
public function create(array $data)
|
||||
{
|
||||
Event::dispatch('customer.customer_group.create.before');
|
||||
|
||||
$customerGroup = $this->model->create($data);
|
||||
|
||||
Event::dispatch('customer.customer_group.create.after', $customerGroup);
|
||||
|
||||
return $customerGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update.
|
||||
*
|
||||
* @param array $data
|
||||
* @param int $id
|
||||
* @param string $id
|
||||
* @return \Webkul\Customer\Contracts\CustomerGroup
|
||||
*/
|
||||
public function update(array $data, $id, $attribute = 'id')
|
||||
{
|
||||
$customer = $this->findOrFail($id);
|
||||
|
||||
Event::dispatch('customer.customer_group.update.before', $id);
|
||||
|
||||
$customerGroup = $customer->update($data);
|
||||
|
||||
Event::dispatch('customer.customer_group.update.after', $customerGroup);
|
||||
|
||||
return $customerGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete.
|
||||
*
|
||||
* @param $id
|
||||
* @return int
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
Event::dispatch('customer.customer_group.delete.before', $id);
|
||||
|
||||
parent::delete($id);
|
||||
|
||||
Event::dispatch('customer.customer_group.delete.after', $id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns guest group.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Webkul\Customer\Repositories;
|
||||
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Webkul\Core\Eloquent\Repository;
|
||||
use Webkul\Sales\Models\Order;
|
||||
|
|
@ -19,40 +18,6 @@ class CustomerRepository extends Repository
|
|||
return \Webkul\Customer\Contracts\Customer::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create customer.
|
||||
*
|
||||
* @param array $attributes
|
||||
* @return mixed
|
||||
*/
|
||||
public function create($attributes)
|
||||
{
|
||||
Event::dispatch('customer.registration.before');
|
||||
|
||||
$customer = parent::create($attributes);
|
||||
|
||||
Event::dispatch('customer.registration.after', $customer);
|
||||
|
||||
return $customer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update customer.
|
||||
*
|
||||
* @param array $attributes
|
||||
* @return mixed
|
||||
*/
|
||||
public function update(array $attributes, $id)
|
||||
{
|
||||
Event::dispatch('customer.update.before');
|
||||
|
||||
$customer = parent::update($attributes, $id);
|
||||
|
||||
Event::dispatch('customer.update.after', $customer);
|
||||
|
||||
return $customer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if customer has order pending or processing.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Webkul\Inventory\Http\Controllers;
|
||||
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Webkul\Admin\DataGrids\InventorySourcesDataGrid;
|
||||
use Webkul\Inventory\Http\Requests\InventorySourceRequest;
|
||||
use Webkul\Inventory\Repositories\InventorySourceRepository;
|
||||
|
|
@ -57,11 +58,13 @@ class InventorySourceController extends Controller
|
|||
*/
|
||||
public function store(InventorySourceRequest $inventorySourceRequest)
|
||||
{
|
||||
$data = $inventorySourceRequest->all();
|
||||
Event::dispatch('inventory.inventory_source.create.before');
|
||||
|
||||
$data['status'] = ! isset($data['status']) ? 0 : 1;
|
||||
$inventorySource = $this->inventorySourceRepository->create(array_merge($inventorySourceRequest->all() ,[
|
||||
'status' => request()->has('status'),
|
||||
]));
|
||||
|
||||
$this->inventorySourceRepository->create($data);
|
||||
Event::dispatch('inventory.inventory_source.create.after', $inventorySource);
|
||||
|
||||
session()->flash('success', trans('admin::app.settings.inventory_sources.create-success'));
|
||||
|
||||
|
|
@ -89,11 +92,13 @@ class InventorySourceController extends Controller
|
|||
*/
|
||||
public function update(InventorySourceRequest $inventorySourceRequest, $id)
|
||||
{
|
||||
$data = $inventorySourceRequest->all();
|
||||
Event::dispatch('inventory.inventory_source.update.before', $id);
|
||||
|
||||
$data['status'] = ! isset($data['status']) ? 0 : 1;
|
||||
$inventorySource = $this->inventorySourceRepository->update(array_merge($inventorySourceRequest->all() ,[
|
||||
'status' => request()->has('status'),
|
||||
]), $id);
|
||||
|
||||
$this->inventorySourceRepository->update($data, $id);
|
||||
Event::dispatch('inventory.inventory_source.update.after', $inventorySource);
|
||||
|
||||
session()->flash('success', trans('admin::app.settings.inventory_sources.update-success'));
|
||||
|
||||
|
|
@ -115,8 +120,12 @@ class InventorySourceController extends Controller
|
|||
}
|
||||
|
||||
try {
|
||||
Event::dispatch('inventory.inventory_source.delete.before', $id);
|
||||
|
||||
$this->inventorySourceRepository->delete($id);
|
||||
|
||||
Event::dispatch('inventory.inventory_source.delete.after', $id);
|
||||
|
||||
return response()->json(['message' => trans('admin::app.settings.inventory_sources.delete-success')]);
|
||||
} catch (\Exception $e) {
|
||||
report($e);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Webkul\Inventory\Repositories;
|
||||
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Webkul\Core\Eloquent\Repository;
|
||||
|
||||
class InventorySourceRepository extends Repository
|
||||
|
|
@ -17,56 +16,6 @@ class InventorySourceRepository extends Repository
|
|||
return \Webkul\Inventory\Contracts\InventorySource::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create.
|
||||
*
|
||||
* @param array $attributes
|
||||
* @return mixed
|
||||
*/
|
||||
public function create(array $attributes)
|
||||
{
|
||||
Event::dispatch('inventory.inventory_source.create.before');
|
||||
|
||||
$inventorySource = parent::create($attributes);
|
||||
|
||||
Event::dispatch('inventory.inventory_source.create.after', $inventorySource);
|
||||
|
||||
return $inventorySource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update.
|
||||
*
|
||||
* @param array $attributes
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function update(array $attributes, $id)
|
||||
{
|
||||
Event::dispatch('inventory.inventory_source.update.before', $id);
|
||||
|
||||
$inventorySource = parent::update($attributes, $id);
|
||||
|
||||
Event::dispatch('inventory.inventory_source.update.after', $inventorySource);
|
||||
|
||||
return $inventorySource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete.
|
||||
*
|
||||
* @param int $id
|
||||
* @return bool
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
Event::dispatch('inventory.inventory_source.delete.before', $id);
|
||||
|
||||
parent::delete($id);
|
||||
|
||||
Event::dispatch('inventory.inventory_source.delete.after', $id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns channel inventory source ids.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Webkul\Marketing\Http\Controllers;
|
||||
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Webkul\Admin\DataGrids\CampaignDataGrid;
|
||||
use Webkul\Marketing\Repositories\CampaignRepository;
|
||||
|
||||
|
|
@ -64,7 +65,11 @@ class CampaignController extends Controller
|
|||
'marketing_event_id' => 'required_if:schedule_type,event',
|
||||
]);
|
||||
|
||||
$this->campaignRepository->create(request()->all());
|
||||
Event::dispatch('marketing.campaigns.create.before');
|
||||
|
||||
$campaign = $this->campaignRepository->create(request()->all());
|
||||
|
||||
Event::dispatch('marketing.campaigns.create.after', $campaign);
|
||||
|
||||
session()->flash('success', trans('admin::app.marketing.campaigns.create-success'));
|
||||
|
||||
|
|
@ -100,7 +105,11 @@ class CampaignController extends Controller
|
|||
'marketing_event_id' => 'required_if:schedule_type,event',
|
||||
]);
|
||||
|
||||
$this->campaignRepository->update(request()->all(), $id);
|
||||
Event::dispatch('marketing.campaigns.update.before', $id);
|
||||
|
||||
$campaign = $this->campaignRepository->update(request()->all(), $id);
|
||||
|
||||
Event::dispatch('marketing.campaigns.update.after', $campaign);
|
||||
|
||||
session()->flash('success', trans('admin::app.marketing.campaigns.update-success'));
|
||||
|
||||
|
|
@ -118,8 +127,12 @@ class CampaignController extends Controller
|
|||
$this->campaignRepository->findOrFail($id);
|
||||
|
||||
try {
|
||||
Event::dispatch('marketing.campaigns.delete.before', $id);
|
||||
|
||||
$this->campaignRepository->delete($id);
|
||||
|
||||
Event::dispatch('marketing.campaigns.delete.after', $id);
|
||||
|
||||
return response()->json(['message' => trans('admin::app.marketing.campaigns.delete-success')]);
|
||||
} catch (\Exception $e) {}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Webkul\Marketing\Http\Controllers;
|
||||
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Webkul\Admin\DataGrids\EventDataGrid;
|
||||
use Webkul\Marketing\Repositories\EventRepository;
|
||||
|
||||
|
|
@ -62,7 +63,11 @@ class EventController extends Controller
|
|||
'date' => 'date|required',
|
||||
]);
|
||||
|
||||
$this->eventRepository->create(request()->all());
|
||||
Event::dispatch('marketing.events.create.before');
|
||||
|
||||
$event = $this->eventRepository->create(request()->all());
|
||||
|
||||
Event::dispatch('marketing.events.create.after', $event);
|
||||
|
||||
session()->flash('success', trans('admin::app.marketing.events.create-success'));
|
||||
|
||||
|
|
@ -102,7 +107,11 @@ class EventController extends Controller
|
|||
'date' => 'date|required',
|
||||
]);
|
||||
|
||||
$this->eventRepository->update(request()->all(), $id);
|
||||
Event::dispatch('marketing.events.update.before', $id);
|
||||
|
||||
$event = $this->eventRepository->update(request()->all(), $id);
|
||||
|
||||
Event::dispatch('marketing.events.update.after', $event);
|
||||
|
||||
session()->flash('success', trans('admin::app.marketing.events.update-success'));
|
||||
|
||||
|
|
@ -120,8 +129,12 @@ class EventController extends Controller
|
|||
$this->eventRepository->findOrFail($id);
|
||||
|
||||
try {
|
||||
Event::dispatch('marketing.events.delete.before', $id);
|
||||
|
||||
$this->eventRepository->delete($id);
|
||||
|
||||
Event::dispatch('marketing.events.delete.after', $id);
|
||||
|
||||
return response()->json(['message' => trans('admin::app.marketing.events.delete-success')]);
|
||||
} catch (\Exception $e) {}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Webkul\Marketing\Http\Controllers;
|
||||
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Webkul\Admin\DataGrids\EmailTemplateDataGrid;
|
||||
use Webkul\Marketing\Repositories\TemplateRepository;
|
||||
|
||||
|
|
@ -62,7 +63,11 @@ class TemplateController extends Controller
|
|||
'content' => 'required',
|
||||
]);
|
||||
|
||||
$this->templateRepository->create(request()->all());
|
||||
Event::dispatch('marketing.templates.create.before');
|
||||
|
||||
$template = $this->templateRepository->create(request()->all());
|
||||
|
||||
Event::dispatch('marketing.templates.create.after', $template);
|
||||
|
||||
session()->flash('success', trans('admin::app.marketing.templates.create-success'));
|
||||
|
||||
|
|
@ -96,7 +101,11 @@ class TemplateController extends Controller
|
|||
'content' => 'required',
|
||||
]);
|
||||
|
||||
$this->templateRepository->update(request()->all(), $id);
|
||||
Event::dispatch('marketing.templates.update.before', $id);
|
||||
|
||||
$template = $this->templateRepository->update(request()->all(), $id);
|
||||
|
||||
Event::dispatch('marketing.templates.update.after', $template);
|
||||
|
||||
session()->flash('success', trans('admin::app.marketing.templates.update-success'));
|
||||
|
||||
|
|
@ -114,8 +123,12 @@ class TemplateController extends Controller
|
|||
$this->templateRepository->findOrFail($id);
|
||||
|
||||
try {
|
||||
Event::dispatch('marketing.templates.delete.before', $id);
|
||||
|
||||
$this->templateRepository->delete($id);
|
||||
|
||||
Event::dispatch('marketing.templates.delete.after', $id);
|
||||
|
||||
return response()->json(['message' => trans('admin::app.marketing.templates.delete-success')]);
|
||||
} catch (\Exception $e) {}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Webkul\Marketing\Repositories;
|
||||
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Webkul\Core\Eloquent\Repository;
|
||||
|
||||
class CampaignRepository extends Repository
|
||||
|
|
@ -16,54 +15,4 @@ class CampaignRepository extends Repository
|
|||
{
|
||||
return \Webkul\Marketing\Contracts\Campaign::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create.
|
||||
*
|
||||
* @param array $attributes
|
||||
* @return mixed
|
||||
*/
|
||||
public function create(array $attributes)
|
||||
{
|
||||
Event::dispatch('marketing.campaigns.create.before');
|
||||
|
||||
$campaign = parent::create($attributes);
|
||||
|
||||
Event::dispatch('marketing.campaigns.create.after', $campaign);
|
||||
|
||||
return $campaign;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update.
|
||||
*
|
||||
* @param array $attributes
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function update(array $attributes, $id)
|
||||
{
|
||||
Event::dispatch('marketing.campaigns.update.before', $id);
|
||||
|
||||
$campaign = parent::update($attributes, $id);
|
||||
|
||||
Event::dispatch('marketing.campaigns.update.after', $campaign);
|
||||
|
||||
return $campaign;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete.
|
||||
*
|
||||
* @param $id
|
||||
* @return int
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
Event::dispatch('marketing.campaigns.delete.before', $id);
|
||||
|
||||
parent::delete($id);
|
||||
|
||||
Event::dispatch('marketing.campaigns.delete.after', $id);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Webkul\Marketing\Repositories;
|
||||
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Webkul\Core\Eloquent\Repository;
|
||||
|
||||
class EventRepository extends Repository
|
||||
|
|
@ -16,54 +15,4 @@ class EventRepository extends Repository
|
|||
{
|
||||
return \Webkul\Marketing\Contracts\Event::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a new entity in repository
|
||||
*
|
||||
* @param array $attributes
|
||||
* @return mixed
|
||||
*/
|
||||
public function create(array $attributes)
|
||||
{
|
||||
Event::dispatch('marketing.events.create.before');
|
||||
|
||||
$event = parent::create($attributes);
|
||||
|
||||
Event::dispatch('marketing.events.create.after', $event);
|
||||
|
||||
return $event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update.
|
||||
*
|
||||
* @param array $attributes
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function update(array $attributes, $id)
|
||||
{
|
||||
Event::dispatch('marketing.events.update.before', $id);
|
||||
|
||||
$event = parent::update($attributes, $id);
|
||||
|
||||
Event::dispatch('marketing.events.update.after', $event);
|
||||
|
||||
return $event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete.
|
||||
*
|
||||
* @param $id
|
||||
* @return int
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
Event::dispatch('marketing.events.delete.before', $id);
|
||||
|
||||
parent::delete($id);
|
||||
|
||||
Event::dispatch('marketing.events.delete.after', $id);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Webkul\Marketing\Repositories;
|
||||
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Webkul\Core\Eloquent\Repository;
|
||||
|
||||
class TemplateRepository extends Repository
|
||||
|
|
@ -16,54 +15,4 @@ class TemplateRepository extends Repository
|
|||
{
|
||||
return \Webkul\Marketing\Contracts\Template::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create.
|
||||
*
|
||||
* @param array $attributes
|
||||
* @return mixed
|
||||
*/
|
||||
public function create(array $attributes)
|
||||
{
|
||||
Event::dispatch('marketing.templates.create.before');
|
||||
|
||||
$template = parent::create($attributes);
|
||||
|
||||
Event::dispatch('marketing.templates.create.after', $template);
|
||||
|
||||
return $template;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update.
|
||||
*
|
||||
* @param array $attributes
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function update(array $attributes, $id)
|
||||
{
|
||||
Event::dispatch('marketing.templates.update.before', $id);
|
||||
|
||||
$template = parent::update($attributes, $id);
|
||||
|
||||
Event::dispatch('marketing.templates.update.after', $template);
|
||||
|
||||
return $template;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete.
|
||||
*
|
||||
* @param int $id
|
||||
* @return int
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
Event::dispatch('marketing.templates.delete.before', $id);
|
||||
|
||||
parent::delete($id);
|
||||
|
||||
Event::dispatch('marketing.templates.delete.after', $id);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Webkul\Notification\Listeners;
|
||||
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Webkul\Notification\Repositories\NotificationRepository;
|
||||
use Webkul\Notification\Events\CreateOrderNotification;
|
||||
use Webkul\Notification\Events\UpdateOrderNotification;
|
||||
|
|
@ -37,11 +36,9 @@ class Order
|
|||
*/
|
||||
public function updateOrder($order)
|
||||
{
|
||||
$orderArray = [
|
||||
event(new UpdateOrderNotification([
|
||||
'id' => $order->id,
|
||||
'status' => $order->status,
|
||||
];
|
||||
|
||||
event(new UpdateOrderNotification($orderArray));
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ namespace Webkul\Payment\Listeners;
|
|||
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
|
||||
use Webkul\Sales\Repositories\OrderRepository;
|
||||
use Webkul\Sales\Repositories\InvoiceRepository;
|
||||
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@ class Transaction
|
|||
|
||||
/**
|
||||
* Save the transaction data for online payment.
|
||||
*
|
||||
* @param \Webkul\Sales\Models\Invoice $invoice
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function saveTransaction($invoice) {
|
||||
|
|
@ -41,27 +41,27 @@ class Transaction
|
|||
|
||||
if ($transactionDetails['statusCode'] == 200) {
|
||||
$transactionData['transaction_id'] = $transactionDetails['result']['id'];
|
||||
$transactionData['status'] = $transactionDetails['result']['status'];
|
||||
$transactionData['type'] = $transactionDetails['result']['intent'];
|
||||
$transactionData['status'] = $transactionDetails['result']['status'];
|
||||
$transactionData['type'] = $transactionDetails['result']['intent'];
|
||||
$transactionData['payment_method'] = $invoice->order->payment->method;
|
||||
$transactionData['order_id'] = $invoice->order->id;
|
||||
$transactionData['invoice_id'] = $invoice->id;
|
||||
$transactionData['data'] = json_encode (
|
||||
array_merge($transactionDetails['result']['purchase_units'],
|
||||
$transactionDetails['result']['payer'])
|
||||
);
|
||||
$transactionData['order_id'] = $invoice->order->id;
|
||||
$transactionData['invoice_id'] = $invoice->id;
|
||||
$transactionData['data'] = json_encode (
|
||||
array_merge($transactionDetails['result']['purchase_units'],
|
||||
$transactionDetails['result']['payer'])
|
||||
);
|
||||
|
||||
$this->orderTransactionRepository->create($transactionData);
|
||||
}
|
||||
}
|
||||
} elseif ($invoice->order->payment->method == 'paypal_standard') {
|
||||
$transactionData['transaction_id'] = $data['txn_id'];
|
||||
$transactionData['status'] = $data['payment_status'];
|
||||
$transactionData['type'] = $data['payment_type'];
|
||||
$transactionData['status'] = $data['payment_status'];
|
||||
$transactionData['type'] = $data['payment_type'];
|
||||
$transactionData['payment_method'] = $invoice->order->payment->method;
|
||||
$transactionData['order_id'] = $invoice->order->id;
|
||||
$transactionData['invoice_id'] = $invoice->id;
|
||||
$transactionData['data'] = json_encode ($data);
|
||||
$transactionData['order_id'] = $invoice->order->id;
|
||||
$transactionData['invoice_id'] = $invoice->id;
|
||||
$transactionData['data'] = json_encode ($data);
|
||||
|
||||
$this->orderTransactionRepository->create($transactionData);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@ class SmartButton extends Paypal
|
|||
$request->headers['PayPal-Partner-Attribution-Id'] = $this->paypalPartnerAttributionId;
|
||||
$request->prefer('return=representation');
|
||||
$request->body = $body;
|
||||
|
||||
return $this->client()->execute($request);
|
||||
}
|
||||
|
||||
|
|
@ -85,8 +86,10 @@ class SmartButton extends Paypal
|
|||
public function captureOrder($orderId)
|
||||
{
|
||||
$request = new OrdersCaptureRequest($orderId);
|
||||
|
||||
$request->headers['PayPal-Partner-Attribution-Id'] = $this->paypalPartnerAttributionId;
|
||||
$request->prefer('return=representation');
|
||||
|
||||
$this->client()->execute($request);
|
||||
}
|
||||
|
||||
|
|
@ -110,6 +113,7 @@ class SmartButton extends Paypal
|
|||
public function getCaptureId($orderId)
|
||||
{
|
||||
$paypalOrderDetails = $this->getOrder($orderId);
|
||||
|
||||
return $paypalOrderDetails->result->purchase_units[0]->payments->captures[0]->id;
|
||||
}
|
||||
|
||||
|
|
@ -121,8 +125,10 @@ class SmartButton extends Paypal
|
|||
public function refundOrder($captureId, $body = [])
|
||||
{
|
||||
$request = new CapturesRefundRequest($captureId);
|
||||
|
||||
$request->headers['PayPal-Partner-Attribution-Id'] = $this->paypalPartnerAttributionId;
|
||||
$request->body = $body;
|
||||
|
||||
return $this->client()->execute($request);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,9 +15,13 @@ class Large implements FilterInterface
|
|||
*/
|
||||
public function applyFilter(Image $image)
|
||||
{
|
||||
$width = core()->getConfigData('catalog.products.cache-large-image.width') != '' ? core()->getConfigData('catalog.products.cache-large-image.width') : 480;
|
||||
$width = core()->getConfigData('catalog.products.cache-large-image.width') != ''
|
||||
? core()->getConfigData('catalog.products.cache-large-image.width')
|
||||
: 480;
|
||||
|
||||
$height = core()->getConfigData('catalog.products.cache-large-image.height') != '' ? core()->getConfigData('catalog.products.cache-large-image.height') : 480;
|
||||
$height = core()->getConfigData('catalog.products.cache-large-image.height') != ''
|
||||
? core()->getConfigData('catalog.products.cache-large-image.height')
|
||||
: 480;
|
||||
|
||||
return $image->resize($width, $height, function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
|
|
|
|||
|
|
@ -15,9 +15,13 @@ class Medium implements FilterInterface
|
|||
*/
|
||||
public function applyFilter(Image $image)
|
||||
{
|
||||
$width = core()->getConfigData('catalog.products.cache-medium-image.width') != '' ? core()->getConfigData('catalog.products.cache-medium-image.width') : 280;
|
||||
$width = core()->getConfigData('catalog.products.cache-medium-image.width') != ''
|
||||
? core()->getConfigData('catalog.products.cache-medium-image.width')
|
||||
: 280;
|
||||
|
||||
$height = core()->getConfigData('catalog.products.cache-medium-image.height') != '' ? core()->getConfigData('catalog.products.cache-medium-image.height') : 280;
|
||||
$height = core()->getConfigData('catalog.products.cache-medium-image.height') != ''
|
||||
? core()->getConfigData('catalog.products.cache-medium-image.height')
|
||||
: 280;
|
||||
|
||||
$image->resize($width, $height, function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
|
|
|
|||
|
|
@ -15,9 +15,13 @@ class Small implements FilterInterface
|
|||
*/
|
||||
public function applyFilter(Image $image)
|
||||
{
|
||||
$width = core()->getConfigData('catalog.products.cache-small-image.width') ? core()->getConfigData('catalog.products.cache-small-image.width') : 120;
|
||||
$width = core()->getConfigData('catalog.products.cache-small-image.width')
|
||||
? core()->getConfigData('catalog.products.cache-small-image.width')
|
||||
: 120;
|
||||
|
||||
$height = core()->getConfigData('catalog.products.cache-small-image.height') ? core()->getConfigData('catalog.products.cache-small-image.height') : 120;
|
||||
$height = core()->getConfigData('catalog.products.cache-small-image.height')
|
||||
? core()->getConfigData('catalog.products.cache-small-image.height')
|
||||
: 120;
|
||||
|
||||
$image->resize($width, $height, function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class PriceUpdate extends Command
|
|||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @param ]Webkul\Product\Repositories\ProductFlatRepository $productFlatRepository
|
||||
* @param \Webkul\Product\Repositories\ProductFlatRepository $productFlatRepository
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(protected ProductFlatRepository $productFlatRepository)
|
||||
|
|
@ -46,30 +46,30 @@ class PriceUpdate extends Command
|
|||
|
||||
$product->min_price = $product->getTypeInstance()->getMinimalPrice();
|
||||
|
||||
$product->max_price = $product->getTypeInstance()->getMaximamPrice();
|
||||
$product->max_price = $product->getTypeInstance()->getMaximumPrice();
|
||||
|
||||
$product->save();
|
||||
|
||||
if ($product->parent) {
|
||||
$product->parent->min_price = $product->parent->getTypeInstance()->getMinimalPrice();
|
||||
|
||||
$product->parent->max_price = $product->parent->getTypeInstance()->getMaximamPrice();
|
||||
$product->parent->max_price = $product->parent->getTypeInstance()->getMaximumPrice();
|
||||
|
||||
$product->parent->save();
|
||||
} else {
|
||||
$bundleProducts = $this->productFlatRepository->getModel()
|
||||
->addSelect('product_flat.*')
|
||||
->distinct()
|
||||
->leftJoin('products', 'product_flat.product_id', 'products.id')
|
||||
->leftJoin('product_bundle_options', 'products.id', 'product_bundle_options.product_id')
|
||||
->leftJoin('product_bundle_option_products', 'product_bundle_options.id', 'product_bundle_option_productsproduct_bundle_option_id')
|
||||
->where('product_bundle_option_products.product_id', $product->product_id)
|
||||
->get();
|
||||
->addSelect('product_flat.*')
|
||||
->distinct()
|
||||
->leftJoin('products', 'product_flat.product_id', 'products.id')
|
||||
->leftJoin('product_bundle_options', 'products.id', 'product_bundle_options.product_id')
|
||||
->leftJoin('product_bundle_option_products', 'product_bundle_options.id', 'product_bundle_option_productsproduct_bundle_option_id')
|
||||
->where('product_bundle_option_products.product_id', $product->product_id)
|
||||
->get();
|
||||
|
||||
foreach ($bundleProducts as $bundleProduct) {
|
||||
$bundleProduct->min_price = $bundleProduct->getTypeInstance()->getMinimalPrice();
|
||||
|
||||
$bundleProduct->max_price = $bundleProduct->getTypeInstance()->getMaximamPrice();
|
||||
$bundleProduct->max_price = $bundleProduct->getTypeInstance()->getMaximumPrice();
|
||||
|
||||
$bundleProduct->save();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@ class Builder extends BaseBuilder
|
|||
$perPage = $perPage ?: $this->model->getPerPage();
|
||||
|
||||
$results = ($total = $this->toBase()->getCountForPagination($columns))
|
||||
? $this->forPage($page, $perPage)->get($columns)
|
||||
: $this->model->newCollection();
|
||||
? $this->forPage($page, $perPage)->get($columns)
|
||||
: $this->model->newCollection();
|
||||
|
||||
return $this->paginator($results, $total, $perPage, $page, [
|
||||
'path' => Paginator::resolveCurrentPath(),
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class ProductAttributeValueFactory extends Factory
|
|||
{
|
||||
return [
|
||||
//'product_id' => Product::factory(),
|
||||
'locale' => 'en',
|
||||
'locale' => 'en',
|
||||
'channel' => 'default',
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,16 +23,16 @@ class ProductDownloadableLinkFactory extends Factory
|
|||
public function definition(): array
|
||||
{
|
||||
$now = date("Y-m-d H:i:s");
|
||||
|
||||
$filename = 'ProductImageExampleForUpload.jpg';
|
||||
$filepath = '/tests/_data/';
|
||||
|
||||
return [
|
||||
'url' => '',
|
||||
'file' => $filepath . $filename,
|
||||
'file_name' => $filename,
|
||||
'type' => 'file',
|
||||
'price' => 0.0000,
|
||||
'downloads' => $this->faker->randomNumber(1),
|
||||
'url' => '',
|
||||
'file' => '/tests/_data/' . $filename,
|
||||
'file_name' => $filename,
|
||||
'type' => 'file',
|
||||
'price' => 0.0000,
|
||||
'downloads' => $this->faker->randomNumber(1),
|
||||
'product_id' => Product::factory(),
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@ class ProductDownloadableLinkTranslationFactory extends Factory
|
|||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'locale' => 'en',
|
||||
'title' => $this->faker->word,
|
||||
'locale' => 'en',
|
||||
'title' => $this->faker->word,
|
||||
'product_downloadable_link_id' => ProductDownloadableLink::factory(),
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@ class ProductInventoryFactory extends Factory
|
|||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'qty' => $this->faker->numberBetween(100, 200),
|
||||
'product_id' => Product::factory(),
|
||||
'qty' => $this->faker->numberBetween(100, 200),
|
||||
'product_id' => Product::factory(),
|
||||
'inventory_source_id' => InventorySource::factory(),
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,10 +23,10 @@ class ProductReviewFactory extends Factory
|
|||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'title' => $this->faker->words(5, true),
|
||||
'rating' => $this->faker->numberBetween(0, 10),
|
||||
'status' => 1,
|
||||
'comment' => $this->faker->sentence(20),
|
||||
'title' => $this->faker->words(5, true),
|
||||
'rating' => $this->faker->numberBetween(0, 10),
|
||||
'status' => 1,
|
||||
'comment' => $this->faker->sentence(20),
|
||||
'product_id' => Product::factory(),
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ class BundleOption extends AbstractProduct
|
|||
'product_id' => $bundleOptionProduct->product_id,
|
||||
'is_default' => $bundleOptionProduct->is_default,
|
||||
'sort_order' => $bundleOptionProduct->sort_order,
|
||||
'in_stock' => $bundleOptionProduct->product->inventories->sum('qty') >= $bundleOptionProduct->qty,
|
||||
'in_stock' => $bundleOptionProduct->product->inventories->sum('qty') >= $bundleOptionProduct->qty,
|
||||
'inventory' => $bundleOptionProduct->product->inventories->sum('qty'),
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -124,20 +124,13 @@ class ConfigurableOption extends AbstractProduct
|
|||
$allowAttributes = $this->getAllowAttributes($product);
|
||||
|
||||
foreach ($allowAttributes as $attribute) {
|
||||
|
||||
$attributeOptionsData = $this->getAttributeOptionsData($attribute, $options);
|
||||
|
||||
if ($attributeOptionsData) {
|
||||
$attributeId = $attribute->id;
|
||||
|
||||
$attributes[] = [
|
||||
'id' => $attributeId,
|
||||
'code' => $attribute->code,
|
||||
'label' => $attribute->name ? $attribute->name : $attribute->admin_name,
|
||||
'swatch_type' => $attribute->swatch_type,
|
||||
'options' => $attributeOptionsData,
|
||||
];
|
||||
}
|
||||
$attributes[] = [
|
||||
'id' => $attribute->id,
|
||||
'code' => $attribute->code,
|
||||
'label' => $attribute->name ? $attribute->name : $attribute->admin_name,
|
||||
'swatch_type' => $attribute->swatch_type,
|
||||
'options' => $this->getAttributeOptionsData($attribute, $options),
|
||||
];
|
||||
}
|
||||
|
||||
return $attributes;
|
||||
|
|
@ -155,17 +148,18 @@ class ConfigurableOption extends AbstractProduct
|
|||
$attributeOptionsData = [];
|
||||
|
||||
foreach ($attribute->options as $attributeOption) {
|
||||
|
||||
$optionId = $attributeOption->id;
|
||||
|
||||
if (isset($options[$attribute->id][$optionId])) {
|
||||
$attributeOptionsData[] = [
|
||||
'id' => $optionId,
|
||||
'label' => $attributeOption->label ? $attributeOption->label : $attributeOption->admin_name,
|
||||
'swatch_value' => $attribute->swatch_type == 'image' ? $attributeOption->swatch_value_url : $attributeOption->swatch_value,
|
||||
'products' => $options[$attribute->id][$optionId],
|
||||
];
|
||||
if (! isset($options[$attribute->id][$optionId])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$attributeOptionsData[] = [
|
||||
'id' => $optionId,
|
||||
'label' => $attributeOption->label ? $attributeOption->label : $attributeOption->admin_name,
|
||||
'swatch_value' => $attribute->swatch_type == 'image' ? $attributeOption->swatch_value_url : $attributeOption->swatch_value,
|
||||
'products' => $options[$attribute->id][$optionId],
|
||||
];
|
||||
}
|
||||
|
||||
return $attributeOptionsData;
|
||||
|
|
|
|||
|
|
@ -60,7 +60,6 @@ class GenerateProduct
|
|||
$brand = Attribute::where(['code' => 'brand'])->first();
|
||||
|
||||
if (! AttributeOption::where(['attribute_id' => $brand->id])->exists()) {
|
||||
|
||||
AttributeOption::create([
|
||||
'admin_name' => 'Webkul Demo Brand (c) 2020',
|
||||
'attribute_id' => $brand->id,
|
||||
|
|
|
|||
|
|
@ -90,10 +90,10 @@ class Review extends AbstractProduct
|
|||
}
|
||||
|
||||
return $reviews[$product->id] = $product->reviews()->where('status', 'approved')
|
||||
->select('rating', DB::raw('count(*) as total'))
|
||||
->groupBy('rating')
|
||||
->orderBy('rating', 'desc')
|
||||
->get();
|
||||
->select('rating', DB::raw('count(*) as total'))
|
||||
->groupBy('rating')
|
||||
->orderBy('rating', 'desc')
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -151,10 +151,10 @@ class SEO
|
|||
public function getProductOffers($product)
|
||||
{
|
||||
return [
|
||||
'@type' => 'Offer',
|
||||
'priceCurrency' => core()->getCurrentCurrencyCode(),
|
||||
'price' => $product->getTypeInstance()->getMinimalPrice(),
|
||||
'availability' => 'https://schema.org/InStock',
|
||||
'@type' => 'Offer',
|
||||
'priceCurrency' => core()->getCurrentCurrencyCode(),
|
||||
'price' => $product->getTypeInstance()->getMinimalPrice(),
|
||||
'availability' => 'https://schema.org/InStock',
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,17 +42,17 @@ class View extends AbstractProduct
|
|||
$attribute->type == 'multiselect'
|
||||
|| $attribute->type == 'checkbox'
|
||||
) {
|
||||
$lables = [];
|
||||
$labels = [];
|
||||
|
||||
$attributeOptions = $attributeOptionReposotory->findWhereIn('id', explode(",", $value));
|
||||
|
||||
foreach ($attributeOptions as $attributeOption) {
|
||||
if ($label = $attributeOption->label) {
|
||||
$lables[] = $label;
|
||||
$labels[] = $label;
|
||||
}
|
||||
}
|
||||
|
||||
$value = implode(", ", $lables);
|
||||
$value = implode(", ", $labels);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -118,8 +118,12 @@ class ProductController extends Controller
|
|||
'sku' => ['required', 'unique:products,sku', new Slug],
|
||||
]);
|
||||
|
||||
Event::dispatch('catalog.product.create.before');
|
||||
|
||||
$product = $this->productRepository->create(request()->all());
|
||||
|
||||
Event::dispatch('catalog.product.create.after', $product);
|
||||
|
||||
session()->flash('success', trans('admin::app.response.create-success', ['name' => 'Product']));
|
||||
|
||||
return redirect()->route($this->_config['redirect'], ['id' => $product->id]);
|
||||
|
|
@ -151,7 +155,11 @@ class ProductController extends Controller
|
|||
*/
|
||||
public function update(ProductForm $request, $id)
|
||||
{
|
||||
$this->productRepository->update(request()->all(), $id);
|
||||
Event::dispatch('catalog.product.update.before', $id);
|
||||
|
||||
$product = $this->productRepository->update(request()->all(), $id);
|
||||
|
||||
Event::dispatch('catalog.product.update.after', $product);
|
||||
|
||||
session()->flash('success', trans('admin::app.response.update-success', ['name' => 'Product']));
|
||||
|
||||
|
|
@ -257,8 +265,12 @@ class ProductController extends Controller
|
|||
$product = $this->productRepository->findOrFail($id);
|
||||
|
||||
try {
|
||||
Event::dispatch('catalog.product.delete.before', $id);
|
||||
|
||||
$this->productRepository->delete($id);
|
||||
|
||||
Event::dispatch('catalog.product.delete.after', $id);
|
||||
|
||||
return response()->json([
|
||||
'message' => trans('admin::app.response.delete-success', ['name' => 'Product']),
|
||||
]);
|
||||
|
|
@ -284,7 +296,11 @@ class ProductController extends Controller
|
|||
$product = $this->productRepository->find($productId);
|
||||
|
||||
if (isset($product)) {
|
||||
Event::dispatch('catalog.product.delete.before', $productId);
|
||||
|
||||
$this->productRepository->delete($productId);
|
||||
|
||||
Event::dispatch('catalog.product.delete.after', $productId);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -313,11 +329,15 @@ class ProductController extends Controller
|
|||
$productIds = explode(',', $data['indexes']);
|
||||
|
||||
foreach ($productIds as $productId) {
|
||||
$this->productRepository->update([
|
||||
Event::dispatch('catalog.product.update.before', $id);
|
||||
|
||||
$product = $this->productRepository->update([
|
||||
'channel' => null,
|
||||
'locale' => null,
|
||||
'status' => $data['update-options'],
|
||||
], $productId);
|
||||
|
||||
Event::dispatch('catalog.product.update.after', $product);
|
||||
}
|
||||
|
||||
session()->flash('success', trans('admin::app.catalog.products.mass-update-success'));
|
||||
|
|
|
|||
|
|
@ -61,7 +61,11 @@ class ReviewController extends Controller
|
|||
*/
|
||||
public function update($id)
|
||||
{
|
||||
$this->productReviewRepository->update(request()->all(), $id);
|
||||
Event::dispatch('customer.review.update.before', $id);
|
||||
|
||||
$review = $this->productReviewRepository->update(request()->all(), $id);
|
||||
|
||||
Event::dispatch('customer.review.update.after', $review);
|
||||
|
||||
session()->flash('success', trans('admin::app.response.update-success', ['name' => 'Review']));
|
||||
|
||||
|
|
@ -79,8 +83,12 @@ class ReviewController extends Controller
|
|||
$this->productReviewRepository->findOrFail($id);
|
||||
|
||||
try {
|
||||
Event::dispatch('customer.review.delete.before', $id);
|
||||
|
||||
$this->productReviewRepository->delete($id);
|
||||
|
||||
Event::dispatch('customer.review.delete.after', $id);
|
||||
|
||||
return response()->json(['message' => trans('admin::app.response.delete-success', ['name' => 'Review'])]);
|
||||
} catch (\Exception $e) {
|
||||
report($e);
|
||||
|
|
@ -99,13 +107,15 @@ class ReviewController extends Controller
|
|||
$suppressFlash = false;
|
||||
|
||||
if (request()->isMethod('post')) {
|
||||
$data = request()->all();
|
||||
|
||||
$indexes = explode(',', request()->input('indexes'));
|
||||
|
||||
foreach ($indexes as $key => $value) {
|
||||
foreach ($indexes as $index) {
|
||||
try {
|
||||
$this->productReviewRepository->delete($value);
|
||||
Event::dispatch('customer.review.delete.before', $index);
|
||||
|
||||
$this->productReviewRepository->delete($index);
|
||||
|
||||
Event::dispatch('customer.review.delete.after', $index);
|
||||
} catch (\Exception $e) {
|
||||
$suppressFlash = true;
|
||||
|
||||
|
|
|
|||
|
|
@ -261,7 +261,7 @@ class ProductFlat
|
|||
|
||||
$productFlat->min_price = $product->getTypeInstance()->getMinimalPrice();
|
||||
|
||||
$productFlat->max_price = $product->getTypeInstance()->getMaximamPrice();
|
||||
$productFlat->max_price = $product->getTypeInstance()->getMaximumPrice();
|
||||
|
||||
if ($parentProduct) {
|
||||
$parentProductFlat = $this->productFlatRepository->findOneWhere([
|
||||
|
|
|
|||
|
|
@ -99,15 +99,17 @@ class ProductImage extends AbstractProduct
|
|||
{
|
||||
static $loadedBaseImages = [];
|
||||
|
||||
if ($product) {
|
||||
if (array_key_exists($product->id, $loadedBaseImages)) {
|
||||
return $loadedBaseImages[$product->id];
|
||||
}
|
||||
|
||||
return $loadedBaseImages[$product->id] = $galleryImages
|
||||
? $galleryImages[0]
|
||||
: $this->otherwiseLoadFromProduct($product);
|
||||
if (! $product) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (array_key_exists($product->id, $loadedBaseImages)) {
|
||||
return $loadedBaseImages[$product->id];
|
||||
}
|
||||
|
||||
return $loadedBaseImages[$product->id] = $galleryImages
|
||||
? $galleryImages[0]
|
||||
: $this->otherwiseLoadFromProduct($product);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ class ProductVideo extends AbstractProduct
|
|||
}
|
||||
|
||||
$videos[] = [
|
||||
'type' => $video->type,
|
||||
'video_url' => Storage::url($video->path),
|
||||
'type' => $video->type,
|
||||
'video_url' => Storage::url($video->path),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,10 +2,7 @@
|
|||
|
||||
namespace Webkul\Product\Repositories;
|
||||
|
||||
use Illuminate\Container\Container as App;
|
||||
use Webkul\Attribute\Repositories\AttributeRepository;
|
||||
use Webkul\Core\Eloquent\Repository;
|
||||
use Webkul\Product\Models\ProductAttributeValueProxy;
|
||||
|
||||
class ProductAttributeValueRepository extends Repository
|
||||
{
|
||||
|
|
@ -30,6 +27,6 @@ class ProductAttributeValueRepository extends Repository
|
|||
{
|
||||
$result = $this->resetScope()->model->where($column, $value)->where('attribute_id', '=', $attributeId)->where('product_id', '!=', $productId)->get();
|
||||
|
||||
return $result->count() ? false : true;
|
||||
return ! $result->count();
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Webkul\Product\Repositories;
|
||||
|
||||
use Illuminate\Container\Container as App;
|
||||
use Illuminate\Container\Container;
|
||||
use Webkul\Core\Eloquent\Repository;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
|
|
@ -12,15 +12,15 @@ class ProductBundleOptionRepository extends Repository
|
|||
* Create a new repository instance.
|
||||
*
|
||||
* @param Webkul\Product\Repositories\ProductBundleOptionProductRepository $productBundleOptionProductRepository
|
||||
* @param \Illuminate\Container\Container $app
|
||||
* @param \Illuminate\Container\Container $container
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
protected ProductBundleOptionProductRepository $productBundleOptionProductRepository,
|
||||
App $app
|
||||
Container $container
|
||||
)
|
||||
{
|
||||
parent::__construct($app);
|
||||
parent::__construct($container);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -28,13 +28,15 @@ class ProductDownloadableLinkRepository extends Repository
|
|||
public function upload($data, $productId)
|
||||
{
|
||||
foreach ($data as $type => $file) {
|
||||
if (request()->hasFile($type)) {
|
||||
return [
|
||||
$type => $path = request()->file($type)->store('product_downloadable_links/' . $productId, 'private'),
|
||||
$type . '_name' => $file->getClientOriginalName(),
|
||||
$type . '_url' => Storage::url($path),
|
||||
];
|
||||
if (! request()->hasFile($type)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return [
|
||||
$type => $path = request()->file($type)->store('product_downloadable_links/' . $productId, 'private'),
|
||||
$type . '_name' => $file->getClientOriginalName(),
|
||||
$type . '_url' => Storage::url($path),
|
||||
];
|
||||
}
|
||||
|
||||
return [];
|
||||
|
|
|
|||
|
|
@ -25,15 +25,15 @@ class ProductDownloadableSampleRepository extends Repository
|
|||
*/
|
||||
public function upload($data, $productId)
|
||||
{
|
||||
if (request()->hasFile('file')) {
|
||||
return [
|
||||
'file' => $path = request()->file('file')->store('product_downloadable_links/' . $productId),
|
||||
'file_name' => request()->file('file')->getClientOriginalName(),
|
||||
'file_url' => Storage::url($path),
|
||||
];
|
||||
if (! request()->hasFile('file')) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return [];
|
||||
return [
|
||||
'file' => $path = request()->file('file')->store('product_downloadable_links/' . $productId),
|
||||
'file_name' => request()->file('file')->getClientOriginalName(),
|
||||
'file_url' => Storage::url($path),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -2,25 +2,25 @@
|
|||
|
||||
namespace Webkul\Product\Repositories;
|
||||
|
||||
use Illuminate\Container\Container as App;
|
||||
use Webkul\Attribute\Repositories\AttributeRepository;
|
||||
use Illuminate\Container\Container;
|
||||
use Webkul\Core\Eloquent\Repository;
|
||||
use Webkul\Attribute\Repositories\AttributeRepository;
|
||||
|
||||
class ProductFlatRepository extends Repository
|
||||
{
|
||||
/**
|
||||
* Create a new repository instance.
|
||||
*
|
||||
* @param \Webkul\Attribute\Repositories\AttributeRepository $attributeRepository
|
||||
* @param \Illuminate\Container\Container $app
|
||||
* @param \Webkul\Attribute\Repositories\AttributeRepository $attributeRepository
|
||||
* @param \Illuminate\Container\Container $container
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
protected AttributeRepository $attributeRepository,
|
||||
App $app
|
||||
Container $container
|
||||
)
|
||||
{
|
||||
parent::__construct($app);
|
||||
parent::__construct($container);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Webkul\Product\Repositories;
|
||||
|
||||
use Illuminate\Container\Container as App;
|
||||
use Illuminate\Container\Container;
|
||||
use Webkul\Product\Repositories\ProductRepository;
|
||||
|
||||
class ProductImageRepository extends ProductMediaRepository
|
||||
|
|
@ -11,15 +11,15 @@ class ProductImageRepository extends ProductMediaRepository
|
|||
* Create a new repository instance.
|
||||
*
|
||||
* @param \Webkul\Product\Repositories\ProductRepository $productRepository
|
||||
* @param \Illuminate\Container\Container $app
|
||||
* @param \Illuminate\Container\Container $container
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
protected ProductRepository $productRepository,
|
||||
App $app
|
||||
Container $container
|
||||
)
|
||||
{
|
||||
parent::__construct($app);
|
||||
parent::__construct($container);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -108,9 +108,7 @@ class ProductMediaRepository extends Repository
|
|||
{
|
||||
if ($uploadFileType === 'images') {
|
||||
return $product->images();
|
||||
}
|
||||
|
||||
if ($uploadFileType === 'videos') {
|
||||
} elseif ($uploadFileType === 'videos') {
|
||||
return $product->videos();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,12 +3,11 @@
|
|||
namespace Webkul\Product\Repositories;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Container\Container as App;
|
||||
use Illuminate\Container\Container;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Pagination\Paginator;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Webkul\Attribute\Models\Attribute;
|
||||
|
|
@ -24,16 +23,16 @@ class ProductRepository extends Repository
|
|||
* Create a new repository instance.
|
||||
*
|
||||
* @param \Webkul\Attribute\Repositories\AttributeRepository $attributeRepository
|
||||
* @param \Illuminate\Container\Container $app
|
||||
* @param \Illuminate\Container\Container $container
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
protected AttributeRepository $attributeRepository,
|
||||
App $app
|
||||
Container $container
|
||||
)
|
||||
{
|
||||
parent::__construct($app);
|
||||
parent::__construct($container);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -54,14 +53,10 @@ class ProductRepository extends Repository
|
|||
*/
|
||||
public function create(array $data)
|
||||
{
|
||||
Event::dispatch('catalog.product.create.before');
|
||||
|
||||
$typeInstance = app(config('product_types.' . $data['type'] . '.class'));
|
||||
|
||||
$product = $typeInstance->create($data);
|
||||
|
||||
Event::dispatch('catalog.product.create.after', $product);
|
||||
|
||||
return $product;
|
||||
}
|
||||
|
||||
|
|
@ -75,8 +70,6 @@ class ProductRepository extends Repository
|
|||
*/
|
||||
public function update(array $data, $id, $attribute = 'id')
|
||||
{
|
||||
Event::dispatch('catalog.product.update.before', $id);
|
||||
|
||||
$product = $this->findOrFail($id);
|
||||
|
||||
$product = $product->getTypeInstance()->update($data, $id, $attribute);
|
||||
|
|
@ -85,26 +78,9 @@ class ProductRepository extends Repository
|
|||
$product['channels'] = $data['channels'];
|
||||
}
|
||||
|
||||
Event::dispatch('catalog.product.update.after', $product);
|
||||
|
||||
return $product;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete product.
|
||||
*
|
||||
* @param int $id
|
||||
* @return void
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
Event::dispatch('catalog.product.delete.before', $id);
|
||||
|
||||
parent::delete($id);
|
||||
|
||||
Event::dispatch('catalog.product.delete.after', $id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve product from slug without throwing an exception.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -4,22 +4,9 @@ namespace Webkul\Product\Repositories;
|
|||
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Webkul\Core\Eloquent\Repository;
|
||||
use Illuminate\Container\Container as App;
|
||||
|
||||
class ProductReviewImageRepository extends Repository
|
||||
{
|
||||
/**
|
||||
* Create a new repository instance.
|
||||
*
|
||||
* @param \Illuminate\Container\Container $app
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(App $app)
|
||||
{
|
||||
parent::__construct($app);
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify Model class name
|
||||
*
|
||||
|
|
@ -37,19 +24,22 @@ class ProductReviewImageRepository extends Repository
|
|||
*/
|
||||
public function uploadImages($data, $review)
|
||||
{
|
||||
if (isset($data['attachments'])) {
|
||||
foreach ($data['attachments'] as $imageId => $image) {
|
||||
$file = 'attachments.' . $imageId;
|
||||
$dir = 'review/' . $review->id;
|
||||
if (! isset($data['attachments'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($image instanceof UploadedFile) {
|
||||
if (request()->hasFile($file)) {
|
||||
$this->create([
|
||||
'path' => request()->file($file)->store($dir),
|
||||
'review_id' => $review->id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
foreach ($data['attachments'] as $imageId => $image) {
|
||||
$file = 'attachments.' . $imageId;
|
||||
$dir = 'review/' . $review->id;
|
||||
|
||||
if (
|
||||
$image instanceof UploadedFile
|
||||
&& request()->hasFile($file)
|
||||
) {
|
||||
$this->create([
|
||||
'path' => request()->file($file)->store($dir),
|
||||
'review_id' => $review->id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Webkul\Product\Repositories;
|
||||
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Webkul\Core\Eloquent\Repository;
|
||||
|
||||
class ProductReviewRepository extends Repository
|
||||
|
|
@ -17,39 +16,6 @@ class ProductReviewRepository extends Repository
|
|||
return \Webkul\Product\Contracts\ProductReview::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update review.
|
||||
*
|
||||
* @param array $attributes
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function update(array $attributes, $id)
|
||||
{
|
||||
Event::dispatch('customer.review.update.before', $id);
|
||||
|
||||
$review = parent::update($attributes, $id);
|
||||
|
||||
Event::dispatch('customer.review.update.after', $review);
|
||||
|
||||
return $review;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a entity in repository by id
|
||||
*
|
||||
* @param $id
|
||||
* @return void
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
Event::dispatch('customer.review.delete.before', $id);
|
||||
|
||||
parent::delete($id);
|
||||
|
||||
Event::dispatch('customer.review.delete.after', $id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve review for customerId
|
||||
*
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
namespace Webkul\Product\Repositories;
|
||||
|
||||
use Webkul\Core\Traits\Sanitizer;
|
||||
use Webkul\Core\Eloquent\Repository;
|
||||
use Illuminate\Container\Container;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Container\Container as App;
|
||||
use Webkul\Core\Eloquent\Repository;
|
||||
use Webkul\Product\Repositories\ProductRepository;
|
||||
use Webkul\Core\Traits\Sanitizer;
|
||||
|
||||
class SearchRepository extends Repository
|
||||
{
|
||||
|
|
@ -15,15 +15,15 @@ class SearchRepository extends Repository
|
|||
* Create a new repository instance.
|
||||
*
|
||||
* @param \Webkul\Product\Repositories\ProductRepository $productRepository
|
||||
* @param \Illuminate\Container\Container $app
|
||||
* @param \Illuminate\Container\Container $container
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
protected ProductRepository $productRepository,
|
||||
App $app
|
||||
Container $container
|
||||
)
|
||||
{
|
||||
parent::__construct($app);
|
||||
parent::__construct($container);
|
||||
}
|
||||
|
||||
function model()
|
||||
|
|
|
|||
|
|
@ -558,7 +558,7 @@ abstract class AbstractType
|
|||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getMaximamPrice()
|
||||
public function getMaximumPrice()
|
||||
{
|
||||
return $this->getMinimalPrice();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -151,14 +151,16 @@ class Bundle extends AbstractType
|
|||
foreach ($this->product->bundle_options as $option) {
|
||||
$optionProductsPrices = $this->getOptionProductsPrices($option);
|
||||
|
||||
if (count($optionProductsPrices)) {
|
||||
$selectionMinPrice = min($optionProductsPrices);
|
||||
if (! count($optionProductsPrices)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($option->is_required) {
|
||||
$minPrice += $selectionMinPrice;
|
||||
} elseif (! $haveRequiredOptions) {
|
||||
$minPrices[] = $selectionMinPrice;
|
||||
}
|
||||
$selectionMinPrice = min($optionProductsPrices);
|
||||
|
||||
if ($option->is_required) {
|
||||
$minPrice += $selectionMinPrice;
|
||||
} elseif (! $haveRequiredOptions) {
|
||||
$minPrices[] = $selectionMinPrice;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -185,14 +187,16 @@ class Bundle extends AbstractType
|
|||
foreach ($this->product->bundle_options as $option) {
|
||||
$optionProductsPrices = $this->getOptionProductsPrices($option, false);
|
||||
|
||||
if (count($optionProductsPrices)) {
|
||||
$selectionMinPrice = min($optionProductsPrices);
|
||||
if (! count($optionProductsPrices)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($option->is_required) {
|
||||
$minPrice += $selectionMinPrice;
|
||||
} elseif (! $haveRequiredOptions) {
|
||||
$minPrices[] = $selectionMinPrice;
|
||||
}
|
||||
$selectionMinPrice = min($optionProductsPrices);
|
||||
|
||||
if ($option->is_required) {
|
||||
$minPrice += $selectionMinPrice;
|
||||
} elseif (! $haveRequiredOptions) {
|
||||
$minPrices[] = $selectionMinPrice;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -253,7 +257,7 @@ class Bundle extends AbstractType
|
|||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getMaximamPrice()
|
||||
public function getMaximumPrice()
|
||||
{
|
||||
$optionPrices = [];
|
||||
|
||||
|
|
@ -290,7 +294,7 @@ class Bundle extends AbstractType
|
|||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getRegularMaximamPrice()
|
||||
public function getRegularMaximumPrice()
|
||||
{
|
||||
$optionPrices = [];
|
||||
|
||||
|
|
@ -354,11 +358,11 @@ class Bundle extends AbstractType
|
|||
|
||||
'to' => [
|
||||
'regular_price' => [
|
||||
'price' => core()->convertPrice($this->evaluatePrice($regularMaximumPrice = $this->getRegularMaximamPrice())),
|
||||
'price' => core()->convertPrice($this->evaluatePrice($regularMaximumPrice = $this->getRegularMaximumPrice())),
|
||||
'formated_price' => core()->currency($this->evaluatePrice($regularMaximumPrice)),
|
||||
],
|
||||
'final_price' => [
|
||||
'price' => core()->convertPrice($this->evaluatePrice($maximumPrice = $this->getMaximamPrice())),
|
||||
'price' => core()->convertPrice($this->evaluatePrice($maximumPrice = $this->getMaximumPrice())),
|
||||
'formated_price' => core()->currency($this->evaluatePrice($maximumPrice)),
|
||||
],
|
||||
],
|
||||
|
|
@ -377,6 +381,7 @@ class Bundle extends AbstractType
|
|||
foreach ($option->bundle_option_products as $index => $bundleOptionProduct) {
|
||||
if ($bundleOptionProduct->product->getTypeInstance()->haveSpecialPrice()) {
|
||||
$haveSpecialPrice = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -755,6 +760,7 @@ class Bundle extends AbstractType
|
|||
continue 2;
|
||||
}
|
||||
}
|
||||
|
||||
# if any required option does not have any in-stock product option we will get here.
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -588,7 +588,7 @@ class Configurable extends AbstractType
|
|||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getMaximamPrice()
|
||||
public function getMaximumPrice()
|
||||
{
|
||||
static $maxPrice = null;
|
||||
|
||||
|
|
|
|||
|
|
@ -124,8 +124,10 @@ class Downloadable extends AbstractType
|
|||
return false;
|
||||
}
|
||||
|
||||
if (is_callable(config('products.isSaleable')) &&
|
||||
call_user_func(config('products.isSaleable'), $this->product) === false) {
|
||||
if (
|
||||
is_callable(config('products.isSaleable'))
|
||||
&& call_user_func(config('products.isSaleable'), $this->product) === false
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -286,7 +288,7 @@ class Downloadable extends AbstractType
|
|||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getMaximamPrice()
|
||||
public function getMaximumPrice()
|
||||
{
|
||||
return $this->product->price;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,11 +61,11 @@ class Simple extends AbstractType
|
|||
*/
|
||||
public function haveSufficientQuantity(int $qty): bool
|
||||
{
|
||||
$backorders = core()->getConfigData('catalog.inventory.stock_options.backorders');
|
||||
$backOrders = core()->getConfigData('catalog.inventory.stock_options.backorders');
|
||||
|
||||
$backorders = ! is_null($backorders) ? $backorders : false;
|
||||
$backOrders = ! is_null($backOrders) ? $backOrders : false;
|
||||
|
||||
return $qty <= $this->totalQuantity() ? true : $backorders;
|
||||
return $qty <= $this->totalQuantity() ? true : $backOrders;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -73,7 +73,7 @@ class Simple extends AbstractType
|
|||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getMaximamPrice()
|
||||
public function getMaximumPrice()
|
||||
{
|
||||
return $this->product->price;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ class Virtual extends AbstractType
|
|||
*/
|
||||
public function haveSufficientQuantity(int $qty): bool
|
||||
{
|
||||
return $qty <= $this->totalQuantity() ? true : false;
|
||||
return $qty <= $this->totalQuantity();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -80,7 +80,7 @@ class Virtual extends AbstractType
|
|||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getMaximamPrice()
|
||||
public function getMaximumPrice()
|
||||
{
|
||||
return $this->product->price;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ class Validator
|
|||
}
|
||||
}
|
||||
|
||||
return $validConditionCount == $totalConditionCount ? true : false;
|
||||
return $validConditionCount == $totalConditionCount;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -105,14 +105,14 @@ class Validator
|
|||
case 'product':
|
||||
if ($attributeCode == 'category_ids') {
|
||||
$value = $entity->product
|
||||
? $entity->product->categories()->pluck('id')->toArray()
|
||||
: $entity->categories()->pluck('id')->toArray();
|
||||
? $entity->product->categories()->pluck('id')->toArray()
|
||||
: $entity->categories()->pluck('id')->toArray();
|
||||
|
||||
return $value;
|
||||
} else {
|
||||
$value = $entity->product
|
||||
? $entity->product->{$attributeCode}
|
||||
: $entity->{$attributeCode};
|
||||
? $entity->product->{$attributeCode}
|
||||
: $entity->{$attributeCode};
|
||||
|
||||
if (! in_array($condition['attribute_type'], ['multiselect', 'checkbox'])) {
|
||||
return $value;
|
||||
|
|
@ -278,12 +278,15 @@ class Validator
|
|||
}
|
||||
|
||||
foreach ($attributeValue as $subValue) {
|
||||
if (is_array($subValue)) {
|
||||
if (self::validateArrayValues($subValue, $conditionValue) === true) {
|
||||
return true;
|
||||
}
|
||||
if (! is_array($subValue)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (self::validateArrayValues($subValue, $conditionValue) === true) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,35 +33,37 @@ class InvoiceFactory extends Factory
|
|||
public function definition(): array
|
||||
{
|
||||
$subTotal = $this->faker->randomFloat(2);
|
||||
|
||||
$shippingAmount = $this->faker->randomFloat(2);
|
||||
|
||||
$taxAmount = $this->faker->randomFloat(2);
|
||||
|
||||
if (!isset($attributes['order_id'])) {
|
||||
if (! isset($attributes['order_id'])) {
|
||||
$attributes['order_id'] = Order::factory();
|
||||
}
|
||||
|
||||
if (!isset($attributes['order_address_id'])) {
|
||||
if (! isset($attributes['order_address_id'])) {
|
||||
$attributes['order_address_id'] = OrderAddress::factory();
|
||||
}
|
||||
|
||||
return [
|
||||
'email_sent' => 0,
|
||||
'total_qty' => $this->faker->randomNumber(),
|
||||
'base_currency_code' => 'EUR',
|
||||
'email_sent' => 0,
|
||||
'total_qty' => $this->faker->randomNumber(),
|
||||
'base_currency_code' => 'EUR',
|
||||
'channel_currency_code' => 'EUR',
|
||||
'order_currency_code' => 'EUR',
|
||||
'sub_total' => $subTotal,
|
||||
'base_sub_total' => $subTotal,
|
||||
'grand_total' => $subTotal,
|
||||
'base_grand_total' => $subTotal,
|
||||
'shipping_amount' => $shippingAmount,
|
||||
'base_shipping_amount' => $shippingAmount,
|
||||
'tax_amount' => $taxAmount,
|
||||
'base_tax_amount' => $taxAmount,
|
||||
'discount_amount' => 0,
|
||||
'base_discount_amount' => 0,
|
||||
'order_id' => $attributes['order_id'],
|
||||
'order_address_id' => $attributes['order_address_id'],
|
||||
'order_currency_code' => 'EUR',
|
||||
'sub_total' => $subTotal,
|
||||
'base_sub_total' => $subTotal,
|
||||
'grand_total' => $subTotal,
|
||||
'base_grand_total' => $subTotal,
|
||||
'shipping_amount' => $shippingAmount,
|
||||
'base_shipping_amount' => $shippingAmount,
|
||||
'tax_amount' => $taxAmount,
|
||||
'base_tax_amount' => $taxAmount,
|
||||
'discount_amount' => 0,
|
||||
'base_discount_amount' => 0,
|
||||
'order_id' => $attributes['order_id'],
|
||||
'order_address_id' => $attributes['order_address_id'],
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,29 +24,29 @@ class InvoiceItemFactory extends Factory
|
|||
public function definition(): array
|
||||
{
|
||||
$basePrice = $this->faker->randomFloat(2);
|
||||
|
||||
$quantity = $this->faker->randomNumber();
|
||||
|
||||
if (!isset($attributes['order_item_id'])) {
|
||||
if (! isset($attributes['order_item_id'])) {
|
||||
$attributes['order_item_id'] = OrderItem::factory();
|
||||
}
|
||||
|
||||
$orderItem = OrderItem::query()
|
||||
->find($attributes['order_item_id']);
|
||||
$orderItem = OrderItem::query()->find($attributes['order_item_id']);
|
||||
|
||||
return [
|
||||
'name' => $this->faker->word,
|
||||
'sku' => $this->faker->unique()->ean13,
|
||||
'qty' => $quantity,
|
||||
'price' => $basePrice,
|
||||
'base_price' => $basePrice,
|
||||
'total' => $quantity * $basePrice,
|
||||
'base_total' => $quantity * $basePrice,
|
||||
'tax_amount' => 0,
|
||||
'name' => $this->faker->word,
|
||||
'sku' => $this->faker->unique()->ean13,
|
||||
'qty' => $quantity,
|
||||
'price' => $basePrice,
|
||||
'base_price' => $basePrice,
|
||||
'total' => $quantity * $basePrice,
|
||||
'base_total' => $quantity * $basePrice,
|
||||
'tax_amount' => 0,
|
||||
'base_tax_amount' => 0,
|
||||
'product_id' => $orderItem->product_id,
|
||||
'product_type' => $orderItem->product_type,
|
||||
'order_item_id' => $attributes['order_item_id'],
|
||||
'invoice_id' => Invoice::factory(),
|
||||
'product_id' => $orderItem->product_id,
|
||||
'product_type' => $orderItem->product_type,
|
||||
'order_item_id' => $attributes['order_item_id'],
|
||||
'invoice_id' => Invoice::factory(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,23 +31,22 @@ class OrderAddressFactory extends Factory
|
|||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
$customer = Customer::factory()
|
||||
->create();
|
||||
$customerAddress = CustomerAddress::factory()
|
||||
->make();
|
||||
$customer = Customer::factory()->create();
|
||||
|
||||
$customerAddress = CustomerAddress::factory()->make();
|
||||
|
||||
return [
|
||||
'first_name' => $customer->first_name,
|
||||
'last_name' => $customer->last_name,
|
||||
'email' => $customer->email,
|
||||
'address1' => $customerAddress->address1,
|
||||
'country' => $customerAddress->country,
|
||||
'state' => $customerAddress->state,
|
||||
'city' => $customerAddress->city,
|
||||
'postcode' => $customerAddress->postcode,
|
||||
'phone' => $customerAddress->phone,
|
||||
'first_name' => $customer->first_name,
|
||||
'last_name' => $customer->last_name,
|
||||
'email' => $customer->email,
|
||||
'address1' => $customerAddress->address1,
|
||||
'country' => $customerAddress->country,
|
||||
'state' => $customerAddress->state,
|
||||
'city' => $customerAddress->city,
|
||||
'postcode' => $customerAddress->postcode,
|
||||
'phone' => $customerAddress->phone,
|
||||
'address_type' => OrderAddress::ADDRESS_TYPE_BILLING,
|
||||
'order_id' => Order::factory(),
|
||||
'order_id' => Order::factory(),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,47 +34,46 @@ class OrderFactory extends Factory
|
|||
public function definition(): array
|
||||
{
|
||||
$lastOrder = DB::table('orders')
|
||||
->orderBy('id', 'desc')
|
||||
->select('id')
|
||||
->first()->id ?? 0;
|
||||
->orderBy('id', 'desc')
|
||||
->select('id')
|
||||
->first()->id ?? 0;
|
||||
|
||||
|
||||
$customer = Customer::factory()
|
||||
->create();
|
||||
$customer = Customer::factory()->create();
|
||||
|
||||
return [
|
||||
'increment_id' => $lastOrder + 1,
|
||||
'status' => 'pending',
|
||||
'channel_name' => 'Default',
|
||||
'is_guest' => 0,
|
||||
'customer_id' => $customer->id,
|
||||
'customer_email' => $customer->email,
|
||||
'customer_first_name' => $customer->first_name,
|
||||
'customer_last_name' => $customer->last_name,
|
||||
'is_gift' => 0,
|
||||
'total_item_count' => 1,
|
||||
'total_qty_ordered' => 1,
|
||||
'base_currency_code' => 'EUR',
|
||||
'channel_currency_code' => 'EUR',
|
||||
'order_currency_code' => 'EUR',
|
||||
'grand_total' => 0.0000,
|
||||
'base_grand_total' => 0.0000,
|
||||
'grand_total_invoiced' => 0.0000,
|
||||
'increment_id' => $lastOrder + 1,
|
||||
'status' => 'pending',
|
||||
'channel_name' => 'Default',
|
||||
'is_guest' => 0,
|
||||
'customer_id' => $customer->id,
|
||||
'customer_email' => $customer->email,
|
||||
'customer_first_name' => $customer->first_name,
|
||||
'customer_last_name' => $customer->last_name,
|
||||
'is_gift' => 0,
|
||||
'total_item_count' => 1,
|
||||
'total_qty_ordered' => 1,
|
||||
'base_currency_code' => 'EUR',
|
||||
'channel_currency_code' => 'EUR',
|
||||
'order_currency_code' => 'EUR',
|
||||
'grand_total' => 0.0000,
|
||||
'base_grand_total' => 0.0000,
|
||||
'grand_total_invoiced' => 0.0000,
|
||||
'base_grand_total_invoiced' => 0.0000,
|
||||
'grand_total_refunded' => 0.0000,
|
||||
'grand_total_refunded' => 0.0000,
|
||||
'base_grand_total_refunded' => 0.0000,
|
||||
'sub_total' => 0.0000,
|
||||
'base_sub_total' => 0.0000,
|
||||
'sub_total_invoiced' => 0.0000,
|
||||
'base_sub_total_invoiced' => 0.0000,
|
||||
'sub_total_refunded' => 0.0000,
|
||||
'base_sub_total_refunded' => 0.0000,
|
||||
'customer_type' => Customer::class,
|
||||
'channel_id' => 1,
|
||||
'channel_type' => Channel::class,
|
||||
'cart_id' => 0,
|
||||
'shipping_method' => 'free_free',
|
||||
'shipping_title' => 'Free Shipping',
|
||||
'sub_total' => 0.0000,
|
||||
'base_sub_total' => 0.0000,
|
||||
'sub_total_invoiced' => 0.0000,
|
||||
'base_sub_total_invoiced' => 0.0000,
|
||||
'sub_total_refunded' => 0.0000,
|
||||
'base_sub_total_refunded' => 0.0000,
|
||||
'customer_type' => Customer::class,
|
||||
'channel_id' => 1,
|
||||
'channel_type' => Channel::class,
|
||||
'cart_id' => 0,
|
||||
'shipping_method' => 'free_free',
|
||||
'shipping_title' => 'Free Shipping',
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,23 +38,23 @@ class OrderItemFactory extends Factory
|
|||
$fallbackPrice = $this->faker->randomFloat(4, 0, 1000);
|
||||
|
||||
return [
|
||||
'sku' => $product->sku,
|
||||
'type' => $product->type,
|
||||
'name' => $product->name,
|
||||
'price' => $product->price ?? $fallbackPrice,
|
||||
'base_price' => $product->price ?? $fallbackPrice,
|
||||
'total' => $product->price ?? $fallbackPrice,
|
||||
'base_total' => $product->price ?? $fallbackPrice,
|
||||
'product_id' => $product->id,
|
||||
'qty_ordered' => 1,
|
||||
'qty_shipped' => 0,
|
||||
'sku' => $product->sku,
|
||||
'type' => $product->type,
|
||||
'name' => $product->name,
|
||||
'price' => $product->price ?? $fallbackPrice,
|
||||
'base_price' => $product->price ?? $fallbackPrice,
|
||||
'total' => $product->price ?? $fallbackPrice,
|
||||
'base_total' => $product->price ?? $fallbackPrice,
|
||||
'product_id' => $product->id,
|
||||
'qty_ordered' => 1,
|
||||
'qty_shipped' => 0,
|
||||
'qty_invoiced' => 0,
|
||||
'qty_canceled' => 0,
|
||||
'qty_refunded' => 0,
|
||||
'additional' => [],
|
||||
'order_id' => Order::factory(),
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
'additional' => [],
|
||||
'order_id' => Order::factory(),
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
'product_type' => Product::class,
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,13 +23,12 @@ class ShipmentFactory extends Factory
|
|||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
$address = OrderAddress::factory()
|
||||
->create();
|
||||
$address = OrderAddress::factory()->create();
|
||||
|
||||
return [
|
||||
'total_qty' => $this->faker->numberBetween(1, 20),
|
||||
'order_id' => $address->order_id,
|
||||
'order_address_id' => $address->id,
|
||||
'total_qty' => $this->faker->numberBetween(1, 20),
|
||||
'order_id' => $address->order_id,
|
||||
'order_address_id' => $address->id,
|
||||
'inventory_source_id' => InventorySource::factory(),
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Webkul\Sales\Repositories;
|
||||
|
||||
use Illuminate\Container\Container as App;
|
||||
use Illuminate\Container\Container;
|
||||
use Webkul\Core\Eloquent\Repository;
|
||||
use Webkul\Sales\Contracts\DownloadableLinkPurchased;
|
||||
use Webkul\Product\Repositories\ProductDownloadableLinkRepository;
|
||||
|
|
@ -13,14 +13,15 @@ class DownloadableLinkPurchasedRepository extends Repository
|
|||
* Create a new repository instance.
|
||||
*
|
||||
* @param \Webkul\Product\Repositories\ProductDownloadableLinkRepository $productDownloadableLinkRepository
|
||||
* @param \Illuminate\Container\Container $container
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
protected ProductDownloadableLinkRepository $productDownloadableLinkRepository,
|
||||
App $app
|
||||
Container $container
|
||||
)
|
||||
{
|
||||
parent::__construct($app);
|
||||
parent::__construct($container);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Webkul\Sales\Repositories;
|
||||
|
||||
use Illuminate\Container\Container as App;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Webkul\Core\Eloquent\Repository;
|
||||
use Webkul\Sales\Contracts\InvoiceItem;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Webkul\Sales\Repositories;
|
||||
|
||||
use Illuminate\Container\Container as App;
|
||||
use Illuminate\Container\Container;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Webkul\Core\Eloquent\Repository;
|
||||
|
|
@ -18,7 +18,7 @@ class InvoiceRepository extends Repository
|
|||
* @param \Webkul\Sales\Repositories\OrderItemRepository $orderItemRepository
|
||||
* @param \Webkul\Sales\Repositories\InvoiceItemRepository $invoiceItemRepository
|
||||
* @param \Webkul\Sales\Repositories\DownloadableLinkPurchasedRepository $downloadableLinkPurchasedRepository
|
||||
* @param \Illuminate\Container\Container $app
|
||||
* @param \Illuminate\Container\Container $container
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
|
|
@ -26,10 +26,10 @@ class InvoiceRepository extends Repository
|
|||
protected OrderItemRepository $orderItemRepository,
|
||||
protected InvoiceItemRepository $invoiceItemRepository,
|
||||
protected DownloadableLinkPurchasedRepository $downloadableLinkPurchasedRepository,
|
||||
App $app
|
||||
Container $container
|
||||
)
|
||||
{
|
||||
parent::__construct($app);
|
||||
parent::__construct($container);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -124,7 +124,6 @@ class OrderItemRepository extends Repository
|
|||
}
|
||||
|
||||
if ($item->product->inventories->count() > 0) {
|
||||
|
||||
$orderedInventory = $item->product->ordered_inventories()
|
||||
->where('channel_id', $orderItem->order->channel_id)
|
||||
->first();
|
||||
|
|
@ -133,6 +132,7 @@ class OrderItemRepository extends Repository
|
|||
$qty = $item->qty_ordered;
|
||||
} else {
|
||||
Log::info('OrderItem has no `qty_ordered`.', ['orderItem' => $item, 'product' => $item->product]);
|
||||
|
||||
if (isset($item->parent->qty_ordered)) {
|
||||
$qty = $item->parent->qty_ordered;
|
||||
} else {
|
||||
|
|
@ -141,6 +141,7 @@ class OrderItemRepository extends Repository
|
|||
'parent' => $item->parent,
|
||||
'product' => $item->product,
|
||||
]);
|
||||
|
||||
$qty = 1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Webkul\Sales\Repositories;
|
||||
|
||||
use Illuminate\Container\Container as App;
|
||||
use Illuminate\Container\Container;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
|
@ -18,16 +18,16 @@ class OrderRepository extends Repository
|
|||
*
|
||||
* @param \Webkul\Sales\Repositories\OrderItemRepository $orderItemRepository
|
||||
* @param \Webkul\Sales\Repositories\DownloadableLinkPurchasedRepository $downloadableLinkPurchasedRepository
|
||||
* @param \Illuminate\Container\Container $app
|
||||
* @param \Illuminate\Container\Container $container
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
protected OrderItemRepository $orderItemRepository,
|
||||
protected DownloadableLinkPurchasedRepository $downloadableLinkPurchasedRepository,
|
||||
App $app
|
||||
Container $container
|
||||
)
|
||||
{
|
||||
parent::__construct($app);
|
||||
parent::__construct($container);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Webkul\Sales\Repositories;
|
||||
|
||||
use Illuminate\Container\Container as App;
|
||||
use Webkul\Core\Eloquent\Repository;
|
||||
use Webkul\Sales\Contracts\RefundItem;
|
||||
|
||||
|
|
@ -52,8 +51,8 @@ class RefundItemRepository extends Repository
|
|||
|
||||
if ($orderItem->parent) {
|
||||
$shippedQty = $orderItem->qty_ordered
|
||||
? ($orderItem->qty_ordered / $orderItem->parent->qty_ordered) * $shipmentItem->qty
|
||||
: $orderItem->parent->qty_ordered;
|
||||
? ($orderItem->qty_ordered / $orderItem->parent->qty_ordered) * $shipmentItem->qty
|
||||
: $orderItem->parent->qty_ordered;
|
||||
} else {
|
||||
$shippedQty = $shipmentItem->qty;
|
||||
}
|
||||
|
|
@ -63,9 +62,9 @@ class RefundItemRepository extends Repository
|
|||
$totalShippedQtyToRefund = $totalShippedQtyToRefund > $shippedQty ? $totalShippedQtyToRefund - $shippedQty : 0;
|
||||
|
||||
$inventory = $product->inventories()
|
||||
// ->where('vendor_id', $data['vendor_id'])
|
||||
->where('inventory_source_id', $shipmentItem->shipment->inventory_source_id)
|
||||
->first();
|
||||
// ->where('vendor_id', $data['vendor_id'])
|
||||
->where('inventory_source_id', $shipmentItem->shipment->inventory_source_id)
|
||||
->first();
|
||||
|
||||
$inventory->update(['qty' => $inventory->qty + $shippedQtyToRefund]);
|
||||
}
|
||||
|
|
@ -77,10 +76,10 @@ class RefundItemRepository extends Repository
|
|||
&& $orderItem->getTypeInstance()->showQuantityBox()
|
||||
) {
|
||||
$inventory = $orderItem->product->inventories()
|
||||
// ->where('vendor_id', $data['vendor_id'])
|
||||
->whereIn('inventory_source_id', $orderItem->order->channel->inventory_sources()->pluck('id'))
|
||||
->orderBy('qty', 'desc')
|
||||
->first();
|
||||
// ->where('vendor_id', $data['vendor_id'])
|
||||
->whereIn('inventory_source_id', $orderItem->order->channel->inventory_sources()->pluck('id'))
|
||||
->orderBy('qty', 'desc')
|
||||
->first();
|
||||
|
||||
if ($inventory) {
|
||||
$inventory->update(['qty' => $inventory->qty + $quantity]);
|
||||
|
|
@ -89,8 +88,8 @@ class RefundItemRepository extends Repository
|
|||
|
||||
if ($quantity) {
|
||||
$orderedInventory = $product->ordered_inventories()
|
||||
->where('channel_id', $orderItem->order->channel->id)
|
||||
->first();
|
||||
->where('channel_id', $orderItem->order->channel->id)
|
||||
->first();
|
||||
|
||||
if (! $orderedInventory) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Webkul\Sales\Repositories;
|
||||
|
||||
use Illuminate\Container\Container as App;
|
||||
use Illuminate\Container\Container;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Webkul\Core\Eloquent\Repository;
|
||||
|
|
@ -17,17 +17,17 @@ class RefundRepository extends Repository
|
|||
* @param \Webkul\Sales\Repositories\OrderItemRepository $orderItemRepository
|
||||
* @param \Webkul\Sales\Repositories\RefundItemRepository $refundItemRepository
|
||||
* @param \Webkul\Sales\Repositories\DownloadableLinkPurchasedRepository $downloadableLinkPurchasedRepository
|
||||
* @param \Illuminate\Container\Container $app
|
||||
* @param \Illuminate\Container\Container $container
|
||||
*/
|
||||
public function __construct(
|
||||
protected OrderRepository $orderRepository,
|
||||
protected OrderItemRepository $orderItemRepository,
|
||||
protected RefundItemRepository $refundItemRepository,
|
||||
protected DownloadableLinkPurchasedRepository $downloadableLinkPurchasedRepository,
|
||||
App $app
|
||||
Container $container
|
||||
)
|
||||
{
|
||||
parent::__construct($app);
|
||||
parent::__construct($container);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue