Recompiled
This commit is contained in:
commit
15a2266a83
|
|
@ -16,9 +16,7 @@ jobs:
|
|||
image: mysql:5.7
|
||||
env:
|
||||
MYSQL_ROOT_PASSWORD: root
|
||||
MYSQL_DATABASE: bagisto_testing
|
||||
MYSQL_USER: bagisto
|
||||
MYSQL_PASSWORD: secret
|
||||
MYSQL_DATABASE: bagisto
|
||||
ports:
|
||||
- 3306
|
||||
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5
|
||||
|
|
@ -42,11 +40,12 @@ jobs:
|
|||
run: |
|
||||
cp .env.example .env.testing
|
||||
set -e
|
||||
sed -i "s|^\(APP_ENV=\s*\).*$|\1testing|" .env.testing
|
||||
sed -i "s|^\(DB_HOST=\s*\).*$|\1127.0.0.1|" .env.testing
|
||||
sed -i "s|^\(DB_PORT=\s*\).*$|\1${{ job.services.mysql.ports['3306'] }}|" .env.testing
|
||||
sed -i "s|^\(DB_DATABASE=\s*\).*$|\1bagisto_testing|" .env.testing
|
||||
sed -i "s|^\(DB_USERNAME=\s*\).*$|\1bagisto|" .env.testing
|
||||
sed -i "s|^\(DB_PASSWORD=\s*\).*$|\1secret|" .env.testing
|
||||
sed -i "s|^\(DB_DATABASE=\s*\).*$|\1bagisto|" .env.testing
|
||||
sed -i "s|^\(DB_USERNAME=\s*\).*$|\1root|" .env.testing
|
||||
sed -i "s|^\(DB_PASSWORD=\s*\).*$|\1root|" .env.testing
|
||||
|
||||
- name: Key Generate
|
||||
run: set -e && php artisan key:generate --env=testing
|
||||
|
|
|
|||
|
|
@ -14,11 +14,11 @@ class Kernel extends HttpKernel
|
|||
* @var array
|
||||
*/
|
||||
protected $middleware = [
|
||||
\App\Http\Middleware\TrustProxies::class,
|
||||
\Illuminate\Http\Middleware\HandleCors::class,
|
||||
\Webkul\Core\Http\Middleware\CheckForMaintenanceMode::class,
|
||||
\App\Http\Middleware\EncryptCookies::class,
|
||||
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
|
||||
\App\Http\Middleware\TrimStrings::class,
|
||||
\Webkul\Core\Http\Middleware\SecureHeaders::class,
|
||||
];
|
||||
|
||||
|
|
@ -29,7 +29,9 @@ class Kernel extends HttpKernel
|
|||
*/
|
||||
protected $middlewareGroups = [
|
||||
'web' => [
|
||||
\Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||
\App\Http\Middleware\EncryptCookies::class,
|
||||
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
\App\Http\Middleware\VerifyCsrfToken::class,
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
|
|
@ -52,6 +54,7 @@ class Kernel extends HttpKernel
|
|||
protected $routeMiddleware = [
|
||||
'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
|
||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
|
||||
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||
|
|
|
|||
|
|
@ -139,14 +139,16 @@
|
|||
"@php artisan migrate:fresh --env=testing",
|
||||
"vendor/bin/codecept run unit",
|
||||
"vendor/bin/codecept run functional",
|
||||
"vendor/bin/codecept run trigger"
|
||||
"vendor/bin/codecept run trigger",
|
||||
"vendor/bin/codecept run api"
|
||||
],
|
||||
"test-win": [
|
||||
"@set -e",
|
||||
"@php artisan migrate:fresh --env=testing",
|
||||
"vendor\\bin\\codecept.bat run unit",
|
||||
"vendor\\bin\\codecept.bat run functional",
|
||||
"vendor\\bin\\codecept.bat run trigger"
|
||||
"vendor\\bin\\codecept.bat run trigger",
|
||||
"vendor\\bin\\codecept.bat run api"
|
||||
]
|
||||
},
|
||||
"config": {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
db-blade-compiler.php
|
||||
debugbar.php
|
||||
dompdf.php
|
||||
excel.php
|
||||
flare.php
|
||||
ignition.php
|
||||
image.php
|
||||
imagecache.php
|
||||
jwt.php
|
||||
repository.php
|
||||
scout.php
|
||||
tinker.php
|
||||
translatable.php
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -146,7 +146,7 @@ class AddressDataGrid extends DataGrid
|
|||
'sortable' => true,
|
||||
'searchable' => false,
|
||||
'closure' => function ($row) {
|
||||
if ($row->default_address == 1) {
|
||||
if ($row->default_address) {
|
||||
return '<span class="badge badge-md badge-success"">' . trans('admin::app.customers.addresses.yes') . '</span>';
|
||||
} else {
|
||||
return trans('admin::app.customers.addresses.dash');
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ class AttributeDataGrid extends DataGrid
|
|||
'sortable' => true,
|
||||
'searchable' => false,
|
||||
'closure' => function ($value) {
|
||||
if ($value->is_required == 1) {
|
||||
if ($value->is_required) {
|
||||
return trans('admin::app.datagrid.true');
|
||||
} else {
|
||||
return trans('admin::app.datagrid.false');
|
||||
|
|
@ -105,7 +105,7 @@ class AttributeDataGrid extends DataGrid
|
|||
'searchable' => false,
|
||||
'filterable' => true,
|
||||
'closure' => function ($value) {
|
||||
if ($value->is_unique == 1) {
|
||||
if ($value->is_unique) {
|
||||
return trans('admin::app.datagrid.true');
|
||||
} else {
|
||||
return trans('admin::app.datagrid.false');
|
||||
|
|
@ -121,7 +121,7 @@ class AttributeDataGrid extends DataGrid
|
|||
'searchable' => false,
|
||||
'filterable' => true,
|
||||
'closure' => function ($value) {
|
||||
if ($value->value_per_locale == 1) {
|
||||
if ($value->value_per_locale) {
|
||||
return trans('admin::app.datagrid.true');
|
||||
} else {
|
||||
return trans('admin::app.datagrid.false');
|
||||
|
|
@ -137,7 +137,7 @@ class AttributeDataGrid extends DataGrid
|
|||
'searchable' => false,
|
||||
'filterable' => true,
|
||||
'closure' => function ($value) {
|
||||
if ($value->value_per_channel == 1) {
|
||||
if ($value->value_per_channel) {
|
||||
return trans('admin::app.datagrid.true');
|
||||
} else {
|
||||
return trans('admin::app.datagrid.false');
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ class CampaignDataGrid extends DataGrid
|
|||
'sortable' => true,
|
||||
'filterable' => true,
|
||||
'closure' => function ($value) {
|
||||
if ($value->status == 1) {
|
||||
if ($value->status) {
|
||||
return trans('admin::app.datagrid.active');
|
||||
} else {
|
||||
return trans('admin::app.datagrid.inactive');
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ class CartRuleCouponsDataGrid extends DataGrid
|
|||
'sortable' => true,
|
||||
'filterable' => true,
|
||||
'closure' => function ($value) {
|
||||
if ($value->end_other_rules == 1) {
|
||||
if ($value->end_other_rules) {
|
||||
return trans('admin::app.datagrid.true');
|
||||
} else {
|
||||
return trans('admin::app.datagrid.false');
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ class CatalogRuleDataGrid extends DataGrid
|
|||
'sortable' => true,
|
||||
'filterable' => true,
|
||||
'closure' => function ($value) {
|
||||
if ($value->status == 1) {
|
||||
if ($value->status) {
|
||||
return trans('admin::app.datagrid.active');
|
||||
} else {
|
||||
return trans('admin::app.datagrid.inactive');
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ class CategoryDataGrid extends DataGrid
|
|||
'searchable' => true,
|
||||
'filterable' => true,
|
||||
'closure' => function ($value) {
|
||||
if ($value->status == 1) {
|
||||
if ($value->status) {
|
||||
return trans('admin::app.datagrid.active');
|
||||
} else {
|
||||
return trans('admin::app.datagrid.inactive');
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ class CategoryProductDataGrid extends DataGrid
|
|||
'searchable' => false,
|
||||
'filterable' => true,
|
||||
'closure' => function ($value) {
|
||||
if ($value->status == 1) {
|
||||
if ($value->status) {
|
||||
return trans('admin::app.datagrid.active');
|
||||
} else {
|
||||
return trans('admin::app.datagrid.inactive');
|
||||
|
|
|
|||
|
|
@ -145,13 +145,13 @@ class CustomerDataGrid extends DataGrid
|
|||
'closure' => function ($row) {
|
||||
$html = '';
|
||||
|
||||
if ($row->status == 1) {
|
||||
if ($row->status) {
|
||||
$html .= '<span class="badge badge-md badge-success">' . trans('admin::app.customers.customers.active') . '</span>';
|
||||
} else {
|
||||
$html .= '<span class="badge badge-md badge-danger">' . trans('admin::app.customers.customers.inactive') . '</span>';
|
||||
}
|
||||
|
||||
if ($row->is_suspended == 1) {
|
||||
if ($row->is_suspended) {
|
||||
$html .= '<span class="badge badge-md badge-danger">' . trans('admin::app.customers.customers.suspended') . '</span>';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ class InventorySourcesDataGrid extends DataGrid
|
|||
'sortable' => true,
|
||||
'filterable' => true,
|
||||
'closure' => function ($value) {
|
||||
if ($value->status == 1) {
|
||||
if ($value->status) {
|
||||
return trans('admin::app.datagrid.active');
|
||||
} else {
|
||||
return trans('admin::app.datagrid.inactive');
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class NewsLetterDataGrid extends DataGrid
|
|||
'sortable' => true,
|
||||
'filterable' => true,
|
||||
'closure' => function ($value) {
|
||||
if ($value->status === 1) {
|
||||
if ($value->status) {
|
||||
return trans('admin::app.datagrid.true');
|
||||
} else {
|
||||
return trans('admin::app.datagrid.false');
|
||||
|
|
|
|||
|
|
@ -204,7 +204,7 @@ class ProductDataGrid extends DataGrid
|
|||
'closure' => function ($value) {
|
||||
$html = '';
|
||||
|
||||
if ($value->status == 1) {
|
||||
if ($value->status) {
|
||||
$html .= '<span class="badge badge-md badge-success">' . trans('admin::app.datagrid.active') . '</span>';
|
||||
} else {
|
||||
$html .= '<span class="badge badge-md badge-danger">' . trans('admin::app.datagrid.inactive') . '</span>';
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ class UserDataGrid extends DataGrid
|
|||
'sortable' => true,
|
||||
'filterable' => true,
|
||||
'closure' => function ($value) {
|
||||
if ($value->status == 1) {
|
||||
if ($value->status) {
|
||||
return trans('admin::app.datagrid.active');
|
||||
} else {
|
||||
return trans('admin::app.datagrid.inactive');
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@ class ConfigurationController extends Controller
|
|||
{
|
||||
if (! request()->route('slug')) {
|
||||
$firstItem = current($this->configTree->items);
|
||||
|
||||
$secondItem = current($firstItem['children']);
|
||||
|
||||
return $this->getSlugs($secondItem);
|
||||
|
|
@ -109,6 +110,7 @@ class ConfigurationController extends Controller
|
|||
foreach ($data['sales']['carriers'] as $carrier) {
|
||||
if ($carrier['active']) {
|
||||
$atLeastOneCarrierEnabled = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -116,6 +118,22 @@ class ConfigurationController extends Controller
|
|||
if (! $atLeastOneCarrierEnabled) {
|
||||
session()->flash('error', trans('admin::app.configuration.enable-atleast-one-shipping'));
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
} elseif (isset($data['sales']['paymentmethods'])) {
|
||||
$atLeastOnePaymentMethodEnabled = false;
|
||||
|
||||
foreach ($data['sales']['paymentmethods'] as $paymentMethod) {
|
||||
if ($paymentMethod['active']) {
|
||||
$atLeastOnePaymentMethodEnabled = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (! $atLeastOnePaymentMethodEnabled) {
|
||||
session()->flash('error', trans('admin::app.configuration.enable-atleast-one-payment'));
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
@ -73,8 +74,6 @@ class AddressController extends Controller
|
|||
'address1' => implode(PHP_EOL, array_filter(request()->input('address1'))),
|
||||
]);
|
||||
|
||||
$data = collect(request()->input())->except('_token')->toArray();
|
||||
|
||||
$this->validate(request(), [
|
||||
'company_name' => 'string',
|
||||
'address1' => 'string|required',
|
||||
|
|
@ -86,15 +85,15 @@ class AddressController extends Controller
|
|||
'vat_id' => new VatIdRule(),
|
||||
]);
|
||||
|
||||
if ($this->customerAddressRepository->create($data)) {
|
||||
session()->flash('success', trans('admin::app.customers.addresses.success-create'));
|
||||
Event::dispatch('customer.addresses.create.before');
|
||||
|
||||
return redirect()->route('admin.customer.edit', ['id' => $data['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')]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -131,18 +130,15 @@ class AddressController extends Controller
|
|||
'vat_id' => new VatIdRule(),
|
||||
]);
|
||||
|
||||
$data = collect(request()->input())->except('_token')->toArray();
|
||||
Event::dispatch('customer.addresses.update.before', $id);
|
||||
|
||||
$address = $this->customerAddressRepository->find($id);
|
||||
$customerAddress = $this->customerAddressRepository->update(request()->all(), $id);
|
||||
|
||||
if ($address) {
|
||||
$this->customerAddressRepository->update($data, $id);
|
||||
Event::dispatch('customer.addresses.update.after', $customerAddress);
|
||||
|
||||
session()->flash('success', trans('admin::app.customers.addresses.success-update'));
|
||||
session()->flash('success', trans('admin::app.customers.addresses.success-update'));
|
||||
|
||||
return redirect()->route('admin.customer.addresses.index', ['id' => $address->customer_id]);
|
||||
}
|
||||
return redirect()->route($this->_config['redirect']);
|
||||
return redirect()->route('admin.customer.addresses.index', ['id' => $customerAddress->customer_id]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -153,11 +149,15 @@ 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')
|
||||
'message' => trans('admin::app.customers.addresses.success-delete')
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
@ -172,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,14 +2,13 @@
|
|||
|
||||
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;
|
||||
use Webkul\Admin\Http\Controllers\Controller;
|
||||
use Webkul\Admin\Mail\NewCustomerNotification;
|
||||
use Webkul\Core\Repositories\ChannelRepository;
|
||||
use Webkul\Customer\Repositories\CustomerAddressRepository;
|
||||
use Webkul\Customer\Repositories\CustomerGroupRepository;
|
||||
use Webkul\Customer\Repositories\CustomerRepository;
|
||||
|
||||
|
|
@ -26,15 +25,11 @@ class CustomerController extends Controller
|
|||
* Create a new controller instance.
|
||||
*
|
||||
* @param \Webkul\Customer\Repositories\CustomerRepository $customerRepository
|
||||
* @param \Webkul\Customer\Repositories\CustomerAddressRepository $customerAddressRepository
|
||||
* @param \Webkul\Customer\Repositories\CustomerGroupRepository $customerGroupRepository
|
||||
* @param \Webkul\Core\Repositories\ChannelRepository $channelRepository
|
||||
*/
|
||||
public function __construct(
|
||||
protected CustomerRepository $customerRepository,
|
||||
protected CustomerAddressRepository $customerAddressRepository,
|
||||
protected CustomerGroupRepository $customerGroupRepository,
|
||||
protected ChannelRepository $channelRepository
|
||||
protected CustomerGroupRepository $customerGroupRepository
|
||||
)
|
||||
{
|
||||
$this->_config = request('_config');
|
||||
|
|
@ -61,11 +56,9 @@ class CustomerController extends Controller
|
|||
*/
|
||||
public function create()
|
||||
{
|
||||
$customerGroup = $this->customerGroupRepository->findWhere([['code', '<>', 'guest']]);
|
||||
$groups = $this->customerGroupRepository->findWhere([['code', '<>', 'guest']]);
|
||||
|
||||
$channelName = $this->channelRepository->all();
|
||||
|
||||
return view($this->_config['view'], compact('customerGroup', 'channelName'));
|
||||
return view($this->_config['view'], compact('groups'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -83,18 +76,20 @@ class CustomerController extends Controller
|
|||
'date_of_birth' => 'date|before:today',
|
||||
]);
|
||||
|
||||
$data = request()->all();
|
||||
|
||||
$password = rand(100000, 10000000);
|
||||
|
||||
$data['password'] = bcrypt($password);
|
||||
Event::dispatch('customer.registration.before');
|
||||
|
||||
$data['is_verified'] = 1;
|
||||
$customer = $this->customerRepository->create(array_merge(request()->all() , [
|
||||
'password' => bcrypt($password),
|
||||
'is_verified' => 1,
|
||||
]));
|
||||
|
||||
$customer = $this->customerRepository->create($data);
|
||||
Event::dispatch('customer.registration.after', $customer);
|
||||
|
||||
try {
|
||||
$configKey = 'emails.general.notifications.emails.general.notifications.customer';
|
||||
|
||||
if (core()->getConfigData($configKey)) {
|
||||
Mail::queue(new NewCustomerNotification($customer, $password));
|
||||
}
|
||||
|
|
@ -116,11 +111,10 @@ class CustomerController extends Controller
|
|||
public function edit($id)
|
||||
{
|
||||
$customer = $this->customerRepository->findOrFail($id);
|
||||
$address = $this->customerAddressRepository->find($id);
|
||||
$customerGroup = $this->customerGroupRepository->findWhere([['code', '<>', 'guest']]);
|
||||
$channelName = $this->channelRepository->all();
|
||||
|
||||
return view($this->_config['view'], compact('customer', 'address', 'customerGroup', 'channelName'));
|
||||
$groups = $this->customerGroupRepository->findWhere([['code', '<>', 'guest']]);
|
||||
|
||||
return view($this->_config['view'], compact('customer', 'groups'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -139,13 +133,14 @@ class CustomerController extends Controller
|
|||
'date_of_birth' => 'date|before:today',
|
||||
]);
|
||||
|
||||
$data = request()->all();
|
||||
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);
|
||||
|
||||
$data['status'] = ! isset($data['status']) ? 0 : 1;
|
||||
|
||||
$data['is_suspended'] = ! isset($data['is_suspended']) ? 0 : 1;
|
||||
|
||||
$this->customerRepository->update($data, $id);
|
||||
Event::dispatch('customer.update.after', $customer);
|
||||
|
||||
session()->flash('success', trans('admin::app.response.update-success', ['name' => 'Customer']));
|
||||
|
||||
|
|
@ -199,15 +194,15 @@ 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'));
|
||||
|
||||
if ($noteTaken) {
|
||||
session()->flash('success', 'Note taken');
|
||||
} else {
|
||||
session()->flash('error', 'Note cannot be taken');
|
||||
}
|
||||
Event::dispatch('customer.update.after', $customer);
|
||||
|
||||
session()->flash('success', 'Note taken');
|
||||
|
||||
return redirect()->route($this->_config['redirect']);
|
||||
}
|
||||
|
|
@ -220,12 +215,17 @@ class CustomerController extends Controller
|
|||
public function massUpdate()
|
||||
{
|
||||
$customerIds = explode(',', request()->input('indexes'));
|
||||
|
||||
$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'));
|
||||
|
|
@ -243,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'));
|
||||
|
|
@ -254,6 +257,7 @@ class CustomerController extends Controller
|
|||
}
|
||||
|
||||
session()->flash('error', trans('admin::app.response.order-pending', ['name' => 'Customers']));
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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,11 +63,13 @@ class CustomerGroupController extends Controller
|
|||
'name' => 'required',
|
||||
]);
|
||||
|
||||
$data = request()->all();
|
||||
Event::dispatch('customer.customer_group.create.before');
|
||||
|
||||
$data['is_user_defined'] = 1;
|
||||
$customerGroup = $this->customerGroupRepository->create(array_merge(request()->all() , [
|
||||
'is_user_defined' => 1,
|
||||
]));
|
||||
|
||||
$this->customerGroupRepository->create($data);
|
||||
Event::dispatch('customer.customer_group.create.after', $customerGroup);
|
||||
|
||||
session()->flash('success', trans('admin::app.response.create-success', ['name' => 'Customer Group']));
|
||||
|
||||
|
|
@ -99,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']));
|
||||
|
||||
|
|
@ -116,21 +123,25 @@ class CustomerGroupController extends Controller
|
|||
{
|
||||
$customerGroup = $this->customerGroupRepository->findOrFail($id);
|
||||
|
||||
if ($customerGroup->is_user_defined == 0) {
|
||||
if (! $customerGroup->is_user_defined) {
|
||||
return response()->json([
|
||||
'message' => trans('admin::app.customers.customers.group-default'),
|
||||
], 400);
|
||||
}
|
||||
|
||||
if (count($customerGroup->customers) > 0) {
|
||||
if ($customerGroup->customers->count()) {
|
||||
return response()->json([
|
||||
'message' => trans('admin::app.response.customer-associate', ['name' => 'Customer Group']),
|
||||
], 400);
|
||||
}
|
||||
|
||||
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) {}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,9 +20,7 @@ class ExportController extends Controller
|
|||
|
||||
$gridName = explode('\\', $criteria['gridName']);
|
||||
|
||||
$path = '\Webkul\Admin\DataGrids' . '\\' . last($gridName);
|
||||
|
||||
$gridInstance = app($path);
|
||||
$gridInstance = app('\Webkul\Admin\DataGrids' . '\\' . last($gridName));
|
||||
|
||||
$records = $gridInstance->export();
|
||||
|
||||
|
|
@ -34,9 +32,7 @@ class ExportController extends Controller
|
|||
|
||||
if ($format == 'csv') {
|
||||
return Excel::download(new DataGridExport($records), last($gridName) . '.csv');
|
||||
}
|
||||
|
||||
if ($format == 'xls') {
|
||||
} elseif ($format == 'xls') {
|
||||
return Excel::download(new DataGridExport($records), last($gridName) . '.xlsx');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -99,21 +99,21 @@ class InvoiceController extends Controller
|
|||
'invoice.items.*' => 'required|numeric|min:0',
|
||||
]);
|
||||
|
||||
$data = request()->all();
|
||||
|
||||
if (! $this->invoiceRepository->haveProductToInvoice($data)) {
|
||||
if (! $this->invoiceRepository->haveProductToInvoice(request()->all())) {
|
||||
session()->flash('error', trans('admin::app.sales.invoices.product-error'));
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
if (! $this->invoiceRepository->isValidQuantity($data)) {
|
||||
if (! $this->invoiceRepository->isValidQuantity(request()->all())) {
|
||||
session()->flash('error', trans('admin::app.sales.invoices.invalid-qty'));
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
$this->invoiceRepository->create(array_merge($data, ['order_id' => $orderId]));
|
||||
$this->invoiceRepository->create(array_merge(request()->all(), [
|
||||
'order_id' => $orderId,
|
||||
]));
|
||||
|
||||
session()->flash('success', trans('admin::app.response.create-success', ['name' => 'Invoice']));
|
||||
|
||||
|
|
@ -148,15 +148,9 @@ class InvoiceController extends Controller
|
|||
|
||||
$invoice = $this->invoiceRepository->findOrFail($id);
|
||||
|
||||
if ($invoice) {
|
||||
$this->sendDuplicateInvoiceMail($invoice, $request->email);
|
||||
$this->sendDuplicateInvoiceMail($invoice, $request->email);
|
||||
|
||||
session()->flash('success', __('admin::app.sales.invoices.invoice-sent'));
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
session()->flash('error', __('admin::app.response.something-went-wrong'));
|
||||
session()->flash('success', trans('admin::app.sales.invoices.invoice-sent'));
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,15 +86,12 @@ class OrderController extends Controller
|
|||
*/
|
||||
public function comment($id)
|
||||
{
|
||||
$data = array_merge(request()->all(), [
|
||||
'order_id' => $id,
|
||||
]);
|
||||
Event::dispatch('sales.order.comment.create.before');
|
||||
|
||||
$data['customer_notified'] = isset($data['customer_notified']) ? 1 : 0;
|
||||
|
||||
Event::dispatch('sales.order.comment.create.before', $data);
|
||||
|
||||
$comment = $this->orderCommentRepository->create($data);
|
||||
$comment = $this->orderCommentRepository->create(array_merge(request()->all(), [
|
||||
'order_id' => $id,
|
||||
'customer_notified' => request()->has('customer_notified'),
|
||||
]));
|
||||
|
||||
Event::dispatch('sales.order.comment.create.after', $comment);
|
||||
|
||||
|
|
|
|||
|
|
@ -96,7 +96,9 @@ class ShipmentController extends Controller
|
|||
return redirect()->back();
|
||||
}
|
||||
|
||||
$this->shipmentRepository->create(array_merge($data, ['order_id' => $orderId]));
|
||||
$this->shipmentRepository->create(array_merge($data, [
|
||||
'order_id' => $orderId,
|
||||
]));
|
||||
|
||||
session()->flash('success', trans('admin::app.response.create-success', ['name' => 'Shipment']));
|
||||
|
||||
|
|
@ -141,7 +143,10 @@ class ShipmentController extends Controller
|
|||
->where('inventory_source_id', $inventorySourceId)
|
||||
->sum('qty');
|
||||
|
||||
if ($child->qty_to_ship < $finalQty || $availableQty < $finalQty) {
|
||||
if (
|
||||
$child->qty_to_ship < $finalQty
|
||||
|| $availableQty < $finalQty
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -150,7 +155,10 @@ class ShipmentController extends Controller
|
|||
->where('inventory_source_id', $inventorySourceId)
|
||||
->sum('qty');
|
||||
|
||||
if ($orderItem->qty_to_ship < $qty || $availableQty < $qty) {
|
||||
if (
|
||||
$orderItem->qty_to_ship < $qty
|
||||
|| $availableQty < $qty
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ namespace Webkul\Admin\Listeners;
|
|||
use Illuminate\Support\Facades\Mail;
|
||||
use Webkul\User\Notifications\AdminUpdatePassword;
|
||||
use Webkul\Customer\Notifications\CustomerUpdatePassword;
|
||||
use Webkul\Customer\Models\Customer;
|
||||
use Webkul\User\Models\Admin;
|
||||
|
||||
class PasswordChange
|
||||
{
|
||||
|
|
@ -17,11 +19,9 @@ class PasswordChange
|
|||
public function sendUpdatePasswordMail($adminOrCustomer)
|
||||
{
|
||||
try {
|
||||
if ($adminOrCustomer instanceof \Webkul\Customer\Models\Customer) {
|
||||
if ($adminOrCustomer instanceof Customer) {
|
||||
Mail::queue(new CustomerUpdatePassword($adminOrCustomer));
|
||||
}
|
||||
|
||||
if ($adminOrCustomer instanceof \Webkul\User\Models\Admin) {
|
||||
} elseif ($adminOrCustomer instanceof Admin) {
|
||||
Mail::queue(new AdminUpdatePassword($adminOrCustomer));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@ class CancelOrderAdminNotification extends Mailable
|
|||
public function build()
|
||||
{
|
||||
return $this->from(core()->getSenderEmailDetails()['email'], core()->getSenderEmailDetails()['name'])
|
||||
->to(core()->getAdminEmailDetails()['email'])
|
||||
->subject(trans('shop::app.mail.order.cancel.subject'))
|
||||
->view('shop::emails.sales.order-cancel-admin');
|
||||
->to(core()->getAdminEmailDetails()['email'])
|
||||
->subject(trans('shop::app.mail.order.cancel.subject'))
|
||||
->view('shop::emails.sales.order-cancel-admin');
|
||||
}
|
||||
}
|
||||
|
|
@ -22,8 +22,8 @@ class CancelOrderNotification extends Mailable
|
|||
public function build()
|
||||
{
|
||||
return $this->from(core()->getSenderEmailDetails()['email'], core()->getSenderEmailDetails()['name'])
|
||||
->to($this->order->customer_email, $this->order->customer_full_name)
|
||||
->subject(trans('shop::app.mail.order.cancel.subject'))
|
||||
->view('shop::emails.sales.order-cancel');
|
||||
->to($this->order->customer_email, $this->order->customer_full_name)
|
||||
->subject(trans('shop::app.mail.order.cancel.subject'))
|
||||
->view('shop::emails.sales.order-cancel');
|
||||
}
|
||||
}
|
||||
|
|
@ -21,7 +21,8 @@ class DuplicateInvoiceNotification extends Mailable
|
|||
public $invoice,
|
||||
public $customerEmail
|
||||
)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the message.
|
||||
|
|
|
|||
|
|
@ -16,12 +16,15 @@ class InvoiceOverdueReminder extends Mailable
|
|||
*
|
||||
* @param \Webkul\Customer\Contracts\Customer $customer
|
||||
* @param \Webkul\Sales\Contracts\Invoice $invoice
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
public $customer,
|
||||
public $invoice
|
||||
)
|
||||
{}
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the message.
|
||||
|
|
@ -31,8 +34,11 @@ class InvoiceOverdueReminder extends Mailable
|
|||
public function build()
|
||||
{
|
||||
return $this->from(core()->getSenderEmailDetails()['email'], core()->getSenderEmailDetails()['name'])
|
||||
->to($this->customer->email)
|
||||
->subject(trans('shop::app.mail.invoice.reminder.subject'))
|
||||
->view('shop::emails.customer.invoice-reminder')->with(['customer' => $this->customer, 'invoice' => $this->invoice]);
|
||||
->to($this->customer->email)
|
||||
->subject(trans('shop::app.mail.invoice.reminder.subject'))
|
||||
->view('shop::emails.customer.invoice-reminder')->with([
|
||||
'customer' => $this->customer,
|
||||
'invoice' => $this->invoice,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -29,8 +29,8 @@ class NewAdminNotification extends Mailable
|
|||
public function build()
|
||||
{
|
||||
return $this->from(core()->getSenderEmailDetails()['email'], core()->getSenderEmailDetails()['name'])
|
||||
->to(core()->getAdminEmailDetails()['email'])
|
||||
->subject(trans('shop::app.mail.order.subject'))
|
||||
->view('shop::emails.sales.new-admin-order');
|
||||
->to(core()->getAdminEmailDetails()['email'])
|
||||
->subject(trans('shop::app.mail.order.subject'))
|
||||
->view('shop::emails.sales.new-admin-order');
|
||||
}
|
||||
}
|
||||
|
|
@ -33,8 +33,11 @@ class NewCustomerNotification extends Mailable
|
|||
public function build()
|
||||
{
|
||||
return $this->from(core()->getSenderEmailDetails()['email'], core()->getSenderEmailDetails()['name'])
|
||||
->to($this->customer->email)
|
||||
->subject(trans('shop::app.mail.customer.new.subject'))
|
||||
->view('shop::emails.customer.new-customer')->with(['customer' => $this->customer, 'password' => $this->password]);
|
||||
->to($this->customer->email)
|
||||
->subject(trans('shop::app.mail.customer.new.subject'))
|
||||
->view('shop::emails.customer.new-customer')->with([
|
||||
'customer' => $this->customer,
|
||||
'password' => $this->password,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -33,8 +33,8 @@ class NewInventorySourceNotification extends Mailable
|
|||
$inventory = $this->shipment->inventory_source;
|
||||
|
||||
return $this->from(core()->getSenderEmailDetails()['email'], core()->getSenderEmailDetails()['name'])
|
||||
->to($inventory->contact_email, $inventory->name)
|
||||
->subject(trans('shop::app.mail.shipment.subject', ['order_id' => $order->increment_id]))
|
||||
->view('shop::emails.sales.new-inventorysource-shipment');
|
||||
->to($inventory->contact_email, $inventory->name)
|
||||
->subject(trans('shop::app.mail.shipment.subject', ['order_id' => $order->increment_id]))
|
||||
->view('shop::emails.sales.new-inventorysource-shipment');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@ class NewInvoiceNotification extends Mailable
|
|||
$order = $this->invoice->order;
|
||||
|
||||
return $this->from(core()->getSenderEmailDetails()['email'], core()->getSenderEmailDetails()['name'])
|
||||
->to($order->customer_email, $order->customer_full_name)
|
||||
->subject(trans('shop::app.mail.invoice.subject', ['order_id' => $order->increment_id]))
|
||||
->view('shop::emails.sales.new-invoice');
|
||||
->to($order->customer_email, $order->customer_full_name)
|
||||
->subject(trans('shop::app.mail.invoice.subject', ['order_id' => $order->increment_id]))
|
||||
->view('shop::emails.sales.new-invoice');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,8 +29,8 @@ class NewOrderNotification extends Mailable
|
|||
public function build()
|
||||
{
|
||||
return $this->from(core()->getSenderEmailDetails()['email'], core()->getSenderEmailDetails()['name'])
|
||||
->to($this->order->customer_email, $this->order->customer_full_name)
|
||||
->subject(trans('shop::app.mail.order.subject'))
|
||||
->view('shop::emails.sales.new-order');
|
||||
->to($this->order->customer_email, $this->order->customer_full_name)
|
||||
->subject(trans('shop::app.mail.order.subject'))
|
||||
->view('shop::emails.sales.new-order');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@ class NewRefundNotification extends Mailable
|
|||
$order = $this->refund->order;
|
||||
|
||||
return $this->from(core()->getSenderEmailDetails()['email'], core()->getSenderEmailDetails()['name'])
|
||||
->to($order->customer_email, $order->customer_full_name)
|
||||
->subject(trans('shop::app.mail.refund.subject', ['order_id' => $order->increment_id]))
|
||||
->view('shop::emails.sales.new-refund');
|
||||
->to($order->customer_email, $order->customer_full_name)
|
||||
->subject(trans('shop::app.mail.refund.subject', ['order_id' => $order->increment_id]))
|
||||
->view('shop::emails.sales.new-refund');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@ class NewShipmentNotification extends Mailable
|
|||
$order = $this->shipment->order;
|
||||
|
||||
return $this->from(core()->getSenderEmailDetails()['email'], core()->getSenderEmailDetails()['name'])
|
||||
->to($order->customer_email, $order->customer_full_name)
|
||||
->subject(trans('shop::app.mail.shipment.subject', ['order_id' => $order->increment_id]))
|
||||
->view('shop::emails.sales.new-shipment');
|
||||
->to($order->customer_email, $order->customer_full_name)
|
||||
->subject(trans('shop::app.mail.shipment.subject', ['order_id' => $order->increment_id]))
|
||||
->view('shop::emails.sales.new-shipment');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,8 +29,8 @@ class OrderCommentNotification extends Mailable
|
|||
public function build()
|
||||
{
|
||||
return $this->from(core()->getSenderEmailDetails()['email'], core()->getSenderEmailDetails()['name'])
|
||||
->to($this->comment->order->customer_email, $this->comment->order->customer_full_name)
|
||||
->subject(trans('shop::app.mail.order.comment.subject', ['order_id' => $this->comment->order->increment_id]))
|
||||
->view('shop::emails.sales.new-order-comment');
|
||||
->to($this->comment->order->customer_email, $this->comment->order->customer_full_name)
|
||||
->subject(trans('shop::app.mail.order.comment.subject', ['order_id' => $this->comment->order->increment_id]))
|
||||
->view('shop::emails.sales.new-order-comment');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,13 +105,15 @@ class AdminServiceProvider extends ServiceProvider
|
|||
&& substr_count($item['key'], '.') == 1
|
||||
) {
|
||||
foreach ($allowedPermissions as $key => $value) {
|
||||
if ($item['key'] == $value) {
|
||||
$neededItem = $allowedPermissions[$key + 1];
|
||||
if ($item['key'] != $value) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (config('menu.admin') as $key1 => $findMatced) {
|
||||
if ($findMatced['key'] == $neededItem) {
|
||||
$item['route'] = $findMatced['route'];
|
||||
}
|
||||
$neededItem = $allowedPermissions[$key + 1];
|
||||
|
||||
foreach (config('menu.admin') as $key1 => $findMatced) {
|
||||
if ($findMatced['key'] == $neededItem) {
|
||||
$item['route'] = $findMatced['route'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
<i class="icon notification-icon active" style="margin-left:0px"></i>
|
||||
</div>
|
||||
|
||||
<div class="dropdown-list bottom-right notification">
|
||||
<div class="dropdown-list bottom-right notification" ref="dropdownList">
|
||||
<div class="dropdown-container">
|
||||
<ul class="notif">
|
||||
<div id="notif-title">{{ title }}</div>
|
||||
|
|
@ -132,34 +132,38 @@ export default {
|
|||
read: 0
|
||||
};
|
||||
|
||||
let this_this = this;
|
||||
let self = this;
|
||||
|
||||
this.$http.get(this.getNotificationUrl, {
|
||||
params: params
|
||||
})
|
||||
.then(function (response) {
|
||||
this_this.notifications = response.data.search_results.data;
|
||||
this_this.totalUnRead = response.data.total_unread;
|
||||
self.notifications = response.data.search_results.data;
|
||||
self.totalUnRead = response.data.total_unread;
|
||||
})
|
||||
.catch(function (error) {})
|
||||
},
|
||||
|
||||
readAll: function () {
|
||||
let this_this = this;
|
||||
let self = this;
|
||||
let dropdownList = this.$refs.dropdownList;
|
||||
|
||||
this.$http.post(this.getReadAllUrl)
|
||||
.then(function (response) {
|
||||
this_this.notifications = response.data.search_results.data;
|
||||
self.notifications = response.data.search_results.data;
|
||||
|
||||
this_this.totalUnRead = response.data.total_unread;
|
||||
self.totalUnRead = response.data.total_unread;
|
||||
|
||||
window.flashMessages.push({
|
||||
'type': 'alert-success',
|
||||
'message': response.data.success_message
|
||||
});
|
||||
|
||||
this_this.$root.addFlashMessages();
|
||||
self.$root.addFlashMessages();
|
||||
})
|
||||
.catch(function (error) {})
|
||||
|
||||
dropdownList.style.display = "none";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ $toggleColor: #3c41ff;
|
|||
min-width: 300px;
|
||||
max-width: 25vw;
|
||||
width: 100vw;
|
||||
height: 100%;
|
||||
height: 90vh;
|
||||
z-index: 1;
|
||||
padding-bottom: 10px;
|
||||
transition: transform 0.3s ease;
|
||||
|
|
|
|||
|
|
@ -741,6 +741,7 @@ return [
|
|||
'no' => 'لا.',
|
||||
'delete' => 'احذف',
|
||||
'enable-atleast-one-shipping' => 'تفعيل طريقة شحن واحدة على الأقل.',
|
||||
'enable-atleast-one-payment' => 'تفعيل طريقة دفع واحدة على الأقل.',
|
||||
|
||||
'tax-categories' => [
|
||||
'title' => 'فئات الضرائب',
|
||||
|
|
|
|||
|
|
@ -627,6 +627,7 @@ return [
|
|||
'quantity-integer' => 'Quantity should be integer.',
|
||||
'quantity-min-zero' => 'Quantity should be greater then zero.',
|
||||
],
|
||||
'video-size' => 'Maximum video size should be like :size',
|
||||
],
|
||||
|
||||
'attributes' => [
|
||||
|
|
@ -746,6 +747,7 @@ return [
|
|||
'no' => 'No',
|
||||
'delete' => 'Delete',
|
||||
'enable-atleast-one-shipping' => 'Enable atleast one shipping method.',
|
||||
'enable-atleast-one-payment' => 'Enable atleast one payment method.',
|
||||
|
||||
'tax-categories' => [
|
||||
'title' => 'Tax Categories',
|
||||
|
|
|
|||
|
|
@ -733,6 +733,8 @@ return [
|
|||
'no' => 'Nein',
|
||||
'delete' => 'Löschen',
|
||||
'enable-atleast-one-shipping' => 'Aktivieren Sie mindestens eine Versandart.',
|
||||
'enable-atleast-one-payment' => 'Aktivieren Sie mindestens eine Zahlungsmethode.',
|
||||
|
||||
'tax-categories' =>
|
||||
[
|
||||
'title' => 'Steuerkategorien',
|
||||
|
|
|
|||
|
|
@ -627,6 +627,7 @@ return [
|
|||
'quantity-integer' => 'Quantity should be integer.',
|
||||
'quantity-min-zero' => 'Quantity should be greater then zero.',
|
||||
],
|
||||
'video-size' => 'Maximum video size should be like :size',
|
||||
],
|
||||
|
||||
'attributes' => [
|
||||
|
|
@ -746,6 +747,7 @@ return [
|
|||
'no' => 'No',
|
||||
'delete' => 'Delete',
|
||||
'enable-atleast-one-shipping' => 'Enable atleast one shipping method.',
|
||||
'enable-atleast-one-payment' => 'Enable atleast one payment method.',
|
||||
|
||||
'tax-categories' => [
|
||||
'title' => 'Tax Categories',
|
||||
|
|
|
|||
|
|
@ -743,6 +743,7 @@ return [
|
|||
'no' => 'No',
|
||||
'delete' => 'Borrar',
|
||||
'enable-atleast-one-shipping' => 'Habilite al menos un método de envío.',
|
||||
'enable-atleast-one-payment' => 'Habilite al menos un método de pago.',
|
||||
|
||||
'tax-categories' => [
|
||||
'title' => 'Categorías de impuestos',
|
||||
|
|
|
|||
|
|
@ -726,6 +726,7 @@ return [
|
|||
'no' => 'خیر',
|
||||
'delete' => 'حذف',
|
||||
'enable-atleast-one-shipping' => 'حداقل یک روش حمل و نقل را فعال کنید.',
|
||||
'enable-atleast-one-payment' => 'حداقل یک روش پرداخت را فعال کنید.',
|
||||
|
||||
'tax-categories' => [
|
||||
'title' => 'دسته بندی های مالیات',
|
||||
|
|
|
|||
|
|
@ -746,6 +746,7 @@ return [
|
|||
'no' => 'Non',
|
||||
'delete' => 'Effacer',
|
||||
'enable-atleast-one-shipping' => 'Activez au moins une méthode d\'expédition.',
|
||||
'enable-atleast-one-payment' => 'Activez au moins un mode de paiement.',
|
||||
|
||||
'tax-categories' => [
|
||||
'title' => 'Catégories de taxes',
|
||||
|
|
|
|||
|
|
@ -627,6 +627,7 @@ return [
|
|||
'quantity-integer' => 'Quantity should be integer.',
|
||||
'quantity-min-zero' => 'Quantity should be greater then zero.',
|
||||
],
|
||||
'video-size' => 'Maximum video size should be like :size',
|
||||
],
|
||||
|
||||
'attributes' => [
|
||||
|
|
@ -746,6 +747,7 @@ return [
|
|||
'no' => 'No',
|
||||
'delete' => 'Delete',
|
||||
'enable-atleast-one-shipping' => 'Enable atleast one shipping method.',
|
||||
'enable-atleast-one-payment' => 'Enable atleast one payment method.',
|
||||
|
||||
'tax-categories' => [
|
||||
'title' => 'Tax Categories',
|
||||
|
|
|
|||
|
|
@ -624,6 +624,7 @@ return [
|
|||
'quantity-integer' => 'Quantity should be integer.',
|
||||
'quantity-min-zero' => 'Quantity should be greater then zero.',
|
||||
],
|
||||
'video-size' => 'Maximum video size should be like :size',
|
||||
],
|
||||
|
||||
'attributes' => [
|
||||
|
|
@ -743,6 +744,7 @@ return [
|
|||
'no' => 'नहीं',
|
||||
'delete' => 'हटाएं',
|
||||
'enable-atleast-one-shipping' => 'कम से कम एक शिपिंग विधि सक्षम करें।',
|
||||
'enable-atleast-one-payment' => 'कम से कम एक भुगतान विधि सक्षम करें।',
|
||||
|
||||
'tax-categories' => [
|
||||
'title' => 'कर श्रेणियाँ',
|
||||
|
|
|
|||
|
|
@ -731,6 +731,7 @@ return [
|
|||
'no' => 'No',
|
||||
'delete' => 'Elimina',
|
||||
'enable-atleast-one-shipping' => 'Abilita almeno un metodo di spedizione.',
|
||||
'enable-atleast-one-payment' => 'Abilita almeno un metodo di pagamento.',
|
||||
|
||||
'tax-categories' => [
|
||||
'title' => 'Categorie IVA',
|
||||
|
|
|
|||
|
|
@ -627,6 +627,7 @@ return [
|
|||
'quantity-integer' => 'Quantity should be integer.',
|
||||
'quantity-min-zero' => 'Quantity should be greater then zero.',
|
||||
],
|
||||
'video-size' => 'Maximum video size should be like :size',
|
||||
],
|
||||
|
||||
'attributes' => [
|
||||
|
|
@ -746,6 +747,7 @@ return [
|
|||
'no' => 'No',
|
||||
'delete' => 'Delete',
|
||||
'enable-atleast-one-shipping' => 'Enable atleast one shipping method.',
|
||||
'enable-atleast-one-payment' => 'Enable atleast one payment method.',
|
||||
|
||||
'tax-categories' => [
|
||||
'title' => 'Tax Categories',
|
||||
|
|
|
|||
|
|
@ -725,6 +725,7 @@ return [
|
|||
'no' => 'Nee',
|
||||
'delete' => 'Verwijder',
|
||||
'enable-atleast-one-shipping' => 'Schakel ten minste één verzendmethode in.',
|
||||
'enable-atleast-one-payment' => 'Schakel ten minste één betaalmethode in.',
|
||||
|
||||
'tax-categories' => [
|
||||
'title' => 'BTW categorieën',
|
||||
|
|
|
|||
|
|
@ -726,6 +726,7 @@ return [
|
|||
'no' => 'Nie',
|
||||
'delete' => 'Usuń',
|
||||
'enable-atleast-one-shipping' => 'Włącz co najmniej jedną metodę wysyłki.',
|
||||
'enable-atleast-one-payment' => 'Włącz co najmniej jedną formę płatności.',
|
||||
|
||||
'tax-categories' => [
|
||||
'title' => 'Kategorie podatkowe',
|
||||
|
|
|
|||
|
|
@ -724,6 +724,7 @@ return [
|
|||
'no' => 'Não',
|
||||
'delete' => 'Deletar',
|
||||
'enable-atleast-one-shipping' => 'Enable atleast one shipping method.',
|
||||
'enable-atleast-one-payment' => 'Enable atleast one payment method.',
|
||||
|
||||
'tax-categories' => [
|
||||
'title' => 'Categorias de Imposto',
|
||||
|
|
|
|||
|
|
@ -627,6 +627,7 @@ return [
|
|||
'quantity-integer' => 'Quantity should be integer.',
|
||||
'quantity-min-zero' => 'Quantity should be greater then zero.',
|
||||
],
|
||||
'video-size' => 'Maximum video size should be like :size',
|
||||
],
|
||||
|
||||
'attributes' => [
|
||||
|
|
@ -746,6 +747,7 @@ return [
|
|||
'no' => 'No',
|
||||
'delete' => 'Delete',
|
||||
'enable-atleast-one-shipping' => 'Включите хотя бы один способ доставки.',
|
||||
'enable-atleast-one-payment' => 'Включите хотя бы один способ оплаты.',
|
||||
|
||||
'tax-categories' => [
|
||||
'title' => 'Tax Categories',
|
||||
|
|
|
|||
|
|
@ -627,6 +627,7 @@ return [
|
|||
'quantity-integer' => 'Quantity should be integer.',
|
||||
'quantity-min-zero' => 'Quantity should be greater then zero.',
|
||||
],
|
||||
'video-size' => 'Maximum video size should be like :size',
|
||||
],
|
||||
|
||||
'attributes' => [
|
||||
|
|
@ -746,6 +747,7 @@ return [
|
|||
'no' => 'No',
|
||||
'delete' => 'Delete',
|
||||
'enable-atleast-one-shipping' => 'Enable atleast one shipping method.',
|
||||
'enable-atleast-one-payment' => 'Enable atleast one payment method.',
|
||||
|
||||
'tax-categories' => [
|
||||
'title' => 'Tax Categories',
|
||||
|
|
|
|||
|
|
@ -731,6 +731,7 @@ return [
|
|||
'no' => 'Hayır',
|
||||
'delete' => 'Sil',
|
||||
'enable-atleast-one-shipping' => 'En az bir gönderim yöntemini etkinleştirin.',
|
||||
'enable-atleast-one-payment' => 'En az bir ödeme yöntemini etkinleştirin.',
|
||||
|
||||
'tax-categories' => [
|
||||
'title' => 'Vergi Kategorileri',
|
||||
|
|
|
|||
|
|
@ -726,6 +726,7 @@ return [
|
|||
'no' => 'No',
|
||||
'delete' => '删除',
|
||||
'enable-atleast-one-shipping' => '啟用至少一種運輸方式',
|
||||
'enable-atleast-one-payment' => '啟用至少一種付款方式。',
|
||||
|
||||
'tax-categories' => [
|
||||
'title' => '税分类',
|
||||
|
|
|
|||
|
|
@ -240,7 +240,7 @@
|
|||
|
||||
<script>
|
||||
var groups = @json($attributeFamily ? $attributeFamily->attribute_groups : []);
|
||||
var custom_attributes = @json($custom_attributes);
|
||||
var custom_attributes = @json($customAttributes);
|
||||
|
||||
Vue.component('group-list', {
|
||||
|
||||
|
|
|
|||
|
|
@ -237,7 +237,7 @@
|
|||
|
||||
<script>
|
||||
var groups = @json($attributeFamily->attribute_groups);
|
||||
var custom_attributes = @json($custom_attributes);
|
||||
var custom_attributes = @json($customAttributes);
|
||||
|
||||
Vue.component('group-list', {
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@
|
|||
class="control-error"
|
||||
v-text="'{{ $errors->first('videos.files.*') }}'">
|
||||
</span>
|
||||
|
||||
<span class="control-info mt-10">{{ __('admin::app.catalog.products.video-size', ['size' => core()->getMaxUploadSize()]) }}</span>
|
||||
</div>
|
||||
|
||||
{!! view_render_event('bagisto.admin.catalog.product.edit_form_accordian.videos.controls.after', ['product' => $product]) !!}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
@elseif ($field['type'] == 'number')
|
||||
|
||||
<input type="number" min="0" v-validate="'{{ $validations }}'" class="control" id="{{ $name }}" name="{{ $name }}" value="{{ old($nameKey) ?: core()->getConfigData($nameKey, $channel, $locale) }}" data-vv-as=""{{ trans($field['title']) }}"">
|
||||
<input type="number" min="{{ $field['name'] == 'minimum_order_amount' ? 1 : 0 }}" v-validate="'{{ $validations }}'" class="control" id="{{ $name }}" name="{{ $name }}" value="{{ old($nameKey) ?: core()->getConfigData($nameKey, $channel, $locale) }}" data-vv-as=""{{ trans($field['title']) }}"">
|
||||
|
||||
@elseif ($field['type'] == 'color')
|
||||
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@
|
|||
<div class="control-group">
|
||||
<label for="customerGroup" >{{ __('admin::app.customers.customers.customer_group') }}</label>
|
||||
<select class="control" id="customerGroup" name="customer_group_id">
|
||||
@foreach ($customerGroup as $group)
|
||||
@foreach ($groups as $group)
|
||||
<option value="{{ $group->id }}"> {{ $group->name}} </>
|
||||
@endforeach
|
||||
</select>
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@
|
|||
@endif
|
||||
|
||||
<select class="control" id="customerGroup" name="customer_group_id">
|
||||
@foreach ($customerGroup as $group)
|
||||
@foreach ($groups as $group)
|
||||
<option value="{{ $group->id }}" {{ $selectedCustomerOption == $group->id ? 'selected' : '' }}>
|
||||
{{ $group->name}}
|
||||
</option>
|
||||
|
|
|
|||
|
|
@ -310,7 +310,7 @@
|
|||
|
||||
{!! view_render_event('bagisto.admin.promotions.cart-rules.create.after') !!}
|
||||
|
||||
<accordian title="{{ __('admin::app.promotions.cart-rules.coupon-codes') }}" :active="false" v-if="coupon_type && use_auto_generation">
|
||||
<accordian title="{{ __('admin::app.promotions.cart-rules.coupon-codes') }}" :active="false" v-if="parseInt(use_auto_generation) && parseInt(coupon_type)">
|
||||
<div slot="body">
|
||||
<create-coupon-form></create-coupon-form>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -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,11 +63,13 @@ class AttributeController extends Controller
|
|||
'type' => 'required',
|
||||
]);
|
||||
|
||||
$data = request()->all();
|
||||
Event::dispatch('catalog.attribute.create.before');
|
||||
|
||||
$data['is_user_defined'] = 1;
|
||||
$attribute = $this->attributeRepository->create(array_merge(request()->all(), [
|
||||
'is_user_defined' => 1,
|
||||
]));
|
||||
|
||||
$this->attributeRepository->create($data);
|
||||
Event::dispatch('catalog.attribute.create.after', $attribute);
|
||||
|
||||
session()->flash('success', trans('admin::app.response.create-success', ['name' => 'Attribute']));
|
||||
|
||||
|
|
@ -113,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']));
|
||||
|
||||
|
|
@ -137,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) {}
|
||||
|
||||
|
|
@ -166,16 +177,18 @@ 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']));
|
||||
|
||||
return redirect()->back();
|
||||
} else {
|
||||
session()->flash('error', trans('admin::app.datagrid.mass-ops.method-error'));
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
@ -53,9 +54,9 @@ class AttributeFamilyController extends Controller
|
|||
{
|
||||
$attributeFamily = $this->attributeFamilyRepository->with(['attribute_groups.custom_attributes'])->findOneByField('code', 'default');
|
||||
|
||||
$custom_attributes = $this->attributeRepository->all(['id', 'code', 'admin_name', 'type']);
|
||||
$customAttributes = $this->attributeRepository->all(['id', 'code', 'admin_name', 'type']);
|
||||
|
||||
return view($this->_config['view'], compact('custom_attributes', 'attributeFamily'));
|
||||
return view($this->_config['view'], compact('attributeFamily', 'customAttributes'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -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']);
|
||||
|
|
@ -87,9 +92,9 @@ class AttributeFamilyController extends Controller
|
|||
{
|
||||
$attributeFamily = $this->attributeFamilyRepository->with(['attribute_groups.custom_attributes'])->findOrFail($id, ['*']);
|
||||
|
||||
$custom_attributes = $this->attributeRepository->all(['id', 'code', 'admin_name', 'type']);
|
||||
$customAttributes = $this->attributeRepository->all(['id', 'code', 'admin_name', 'type']);
|
||||
|
||||
return view($this->_config['view'], compact('attributeFamily', 'custom_attributes'));
|
||||
return view($this->_config['view'], compact('attributeFamily', 'customAttributes'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -56,8 +56,8 @@ class Attribute extends TranslatableModel implements AttributeContract
|
|||
public function scopeFilterableAttributes(Builder $query): Builder
|
||||
{
|
||||
return $query->where('is_filterable', 1)
|
||||
->where('swatch_type', '<>', 'image')
|
||||
->orderBy('position');
|
||||
->where('swatch_type', '<>', 'image')
|
||||
->orderBy('position');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -27,10 +27,10 @@ class AttributeFamily extends Model implements AttributeFamilyContract
|
|||
public function custom_attributes()
|
||||
{
|
||||
return (AttributeProxy::modelClass())::join('attribute_group_mappings', 'attributes.id', '=', 'attribute_group_mappings.attribute_id')
|
||||
->join('attribute_groups', 'attribute_group_mappings.attribute_group_id', '=', 'attribute_groups.id')
|
||||
->join('attribute_families', 'attribute_groups.attribute_family_id', '=', 'attribute_families.id')
|
||||
->where('attribute_families.id', $this->id)
|
||||
->select('attributes.*');
|
||||
->join('attribute_groups', 'attribute_group_mappings.attribute_group_id', '=', 'attribute_groups.id')
|
||||
->join('attribute_families', 'attribute_groups.attribute_family_id', '=', 'attribute_families.id')
|
||||
->where('attribute_families.id', $this->id)
|
||||
->select('attributes.*');
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class AttributeGroup extends Model implements AttributeGroupContract
|
|||
public function custom_attributes()
|
||||
{
|
||||
return $this->belongsToMany(AttributeProxy::modelClass(), 'attribute_group_mappings')
|
||||
->withPivot('position')
|
||||
->orderBy('pivot_position', 'asc');
|
||||
->withPivot('position')
|
||||
->orderBy('pivot_position', 'asc');
|
||||
}
|
||||
}
|
||||
|
|
@ -2,37 +2,37 @@
|
|||
|
||||
namespace Webkul\Attribute\Repositories;
|
||||
|
||||
use Illuminate\Container\Container;
|
||||
use Illuminate\Support\Str;
|
||||
use Webkul\Core\Eloquent\Repository;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Webkul\Attribute\Repositories\AttributeRepository;
|
||||
use Webkul\Attribute\Repositories\AttributeGroupRepository;
|
||||
use Illuminate\Container\Container as App;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class AttributeFamilyRepository extends Repository
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
* Create a new repository instance.
|
||||
*
|
||||
* @param \Webkul\Attribute\Repositories\AttributeRepository $attributeRepository
|
||||
* @param \Webkul\Attribute\Repositories\AttributeGroupRepository $attributeGroupRepository
|
||||
* @param \Illuminate\Container\Container $container
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
protected AttributeRepository $attributeRepository,
|
||||
protected AttributeGroupRepository $attributeGroupRepository,
|
||||
App $app
|
||||
Container $container
|
||||
)
|
||||
{
|
||||
parent::__construct($app);
|
||||
parent::__construct($container);
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify Model class name
|
||||
*
|
||||
* @return mixed
|
||||
* @return string
|
||||
*/
|
||||
function model()
|
||||
function model(): string
|
||||
{
|
||||
return 'Webkul\Attribute\Contracts\AttributeFamily';
|
||||
}
|
||||
|
|
@ -43,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']);
|
||||
|
|
@ -69,8 +67,6 @@ class AttributeFamilyRepository extends Repository
|
|||
}
|
||||
}
|
||||
|
||||
Event::dispatch('catalog.attribute_family.create.after', $family);
|
||||
|
||||
return $family;
|
||||
}
|
||||
|
||||
|
|
@ -83,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');
|
||||
|
|
@ -136,8 +130,6 @@ class AttributeFamilyRepository extends Repository
|
|||
$this->attributeGroupRepository->delete($attributeGroupId);
|
||||
}
|
||||
|
||||
Event::dispatch('catalog.attribute_family.update.after', $family);
|
||||
|
||||
return $family;
|
||||
}
|
||||
|
||||
|
|
@ -166,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);
|
||||
}
|
||||
}
|
||||
|
|
@ -10,9 +10,9 @@ class AttributeGroupRepository extends Repository
|
|||
/**
|
||||
* Specify Model class name
|
||||
*
|
||||
* @return mixed
|
||||
* @return string
|
||||
*/
|
||||
function model()
|
||||
function model(): string
|
||||
{
|
||||
return 'Webkul\Attribute\Contracts\AttributeGroup';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@ class AttributeOptionRepository extends Repository
|
|||
/**
|
||||
* Specify Model class name
|
||||
*
|
||||
* @return mixed
|
||||
* @return string
|
||||
*/
|
||||
function model()
|
||||
function model(): string
|
||||
{
|
||||
return 'Webkul\Attribute\Contracts\AttributeOption';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,13 +6,12 @@ use Webkul\Core\Eloquent\Repository;
|
|||
|
||||
class AttributeOptionTranslationRepository extends Repository
|
||||
{
|
||||
|
||||
/**
|
||||
* Specify Model class name
|
||||
*
|
||||
* @return mixed
|
||||
* @return string
|
||||
*/
|
||||
function model()
|
||||
function model(): string
|
||||
{
|
||||
return 'Webkul\Attribute\Contracts\AttributeOptionTranslation';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,7 @@
|
|||
|
||||
namespace Webkul\Attribute\Repositories;
|
||||
|
||||
use Illuminate\Container\Container as App;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Container\Container;
|
||||
use Webkul\Attribute\Repositories\AttributeOptionRepository;
|
||||
use Webkul\Core\Eloquent\Repository;
|
||||
|
||||
|
|
@ -13,22 +12,23 @@ class AttributeRepository extends Repository
|
|||
* Create a new repository instance.
|
||||
*
|
||||
* @param \Webkul\Attribute\Repositories\AttributeOptionRepository $attributeOptionRepository
|
||||
* @param \Illuminate\Container\Container $container
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
protected AttributeOptionRepository $attributeOptionRepository,
|
||||
App $app
|
||||
Container $container
|
||||
)
|
||||
{
|
||||
parent::__construct($app);
|
||||
parent::__construct($container);
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify model class name.
|
||||
*
|
||||
* @return mixed
|
||||
* @return string
|
||||
*/
|
||||
public function model()
|
||||
public function model(): string
|
||||
{
|
||||
return 'Webkul\Attribute\Contracts\Attribute';
|
||||
}
|
||||
|
|
@ -41,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'] : [];
|
||||
|
|
@ -62,8 +60,6 @@ class AttributeRepository extends Repository
|
|||
}
|
||||
}
|
||||
|
||||
Event::dispatch('catalog.attribute.create.after', $attribute);
|
||||
|
||||
return $attribute;
|
||||
}
|
||||
|
||||
|
|
@ -81,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);
|
||||
|
|
@ -109,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.
|
||||
*
|
||||
|
|
@ -260,29 +237,18 @@ class AttributeRepository extends Repository
|
|||
foreach ($attributes as $key => $attribute) {
|
||||
if (
|
||||
$attribute->code != 'tax_category_id'
|
||||
&& ($attribute->type == 'select'
|
||||
|| $attribute->type == 'multiselect'
|
||||
|| $attribute->code == 'sku')
|
||||
&& (
|
||||
in_array($attribute->type ,['select', 'multiselect'])
|
||||
|| $attribute->code == 'sku'
|
||||
)
|
||||
) {
|
||||
if ($attribute->options()->exists()) {
|
||||
array_push($trimmed, [
|
||||
'id' => $attribute->id,
|
||||
'name' => $attribute->admin_name,
|
||||
'type' => $attribute->type,
|
||||
'code' => $attribute->code,
|
||||
'has_options' => true,
|
||||
'options' => $attribute->options,
|
||||
]);
|
||||
} else {
|
||||
array_push($trimmed, [
|
||||
'id' => $attribute->id,
|
||||
'name' => $attribute->admin_name,
|
||||
'type' => $attribute->type,
|
||||
'code' => $attribute->code,
|
||||
'has_options' => false,
|
||||
'options' => null,
|
||||
]);
|
||||
}
|
||||
array_push($trimmed, [
|
||||
'id' => $attribute->id,
|
||||
'name' => $attribute->admin_name,
|
||||
'type' => $attribute->type,
|
||||
'code' => $attribute->code,
|
||||
'options' => $attribute->options,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -37,7 +37,15 @@ class Booking
|
|||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected $daysOfWeek = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
|
||||
protected $daysOfWeek = [
|
||||
'Sunday',
|
||||
'Monday',
|
||||
'Tuesday',
|
||||
'Wednesday',
|
||||
'Thursday',
|
||||
'Friday',
|
||||
'Saturday',
|
||||
];
|
||||
|
||||
/**
|
||||
* Create a new helper instance.
|
||||
|
|
@ -95,7 +103,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 +114,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 +136,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 +170,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 (
|
||||
|
|
@ -221,6 +230,7 @@ class Booking
|
|||
|
||||
foreach ($slots as $index => $slot) {
|
||||
$slots[$index]['from'] = Carbon::createFromTimeString($slot['from'])->format("h:i a");
|
||||
|
||||
$slots[$index]['to'] = Carbon::createFromTimeString($slot['to'])->format("h:i a");
|
||||
}
|
||||
|
||||
|
|
@ -250,16 +260,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 +397,7 @@ class Booking
|
|||
return $slot['timestamp'] == $cartItem['additional']['booking']['slot'];
|
||||
});
|
||||
|
||||
return count($filtered) ? false : true;
|
||||
return ! count($filtered);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -399,12 +409,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;
|
||||
}
|
||||
|
|
@ -576,10 +586,6 @@ class Booking
|
|||
*/
|
||||
public function isCartItemInactive(\Webkul\Checkout\Contracts\CartItem $item): bool
|
||||
{
|
||||
if ($item->product->status === 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return ! $item->product->status;
|
||||
}
|
||||
}
|
||||
|
|
@ -12,7 +12,7 @@ class DefaultSlot extends Booking
|
|||
protected $daysOfWeek = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
|
||||
|
||||
/**
|
||||
* Returns slots for a perticular day
|
||||
* Returns slots for a particular day
|
||||
*
|
||||
* @param \Webkul\BookingProduct\Contracts\BookingProduct $bookingProduct
|
||||
* @param string $date
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -98,19 +98,19 @@ class DefaultSlot extends Booking
|
|||
* @param string $requestedDate
|
||||
* @return array
|
||||
*/
|
||||
public function getManyBookingsforOneDaySlots($bookingProductSlot, $requestedDate)
|
||||
public function getManyBookingsForOneDaySlots($bookingProductSlot, $requestedDate)
|
||||
{
|
||||
$bookingProduct = $bookingProductSlot->booking_product;
|
||||
|
||||
$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;
|
||||
}
|
||||
|
|
@ -186,7 +187,15 @@ class EventTicket extends Booking
|
|||
{
|
||||
return $ticket->special_price !== null
|
||||
&& $ticket->special_price > 0.0
|
||||
&& ($ticket->special_price_from === null || $ticket->special_price_from === '0000-00-00 00:00:00' || $ticket->special_price_from <= Carbon::now())
|
||||
&& ($ticket->special_price_to === null || $ticket->special_price_to === '0000-00-00 00:00:00' || $ticket->special_price_to > Carbon::now());
|
||||
&& (
|
||||
$ticket->special_price_from === null
|
||||
|| $ticket->special_price_from === '0000-00-00 00:00:00'
|
||||
|| $ticket->special_price_from <= Carbon::now()
|
||||
)
|
||||
&& (
|
||||
$ticket->special_price_to === null
|
||||
|| $ticket->special_price_to === '0000-00-00 00:00:00'
|
||||
|| $ticket->special_price_to > Carbon::now()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -21,11 +21,11 @@ class BookingProductController extends Controller
|
|||
* Create a new controller instance.
|
||||
*
|
||||
* @param \Webkul\BookingProduct\Repositories\BookingProductRepository $bookingProductRepository
|
||||
* @param \Webkul\BookingProduct\Helpers\DefaultSlot $defaultSlotHelper
|
||||
* @param \Webkul\BookingProduct\Helpers\AppointmentSlot $appointmentSlotHelper
|
||||
* @param \Webkul\BookingProduct\Helpers\RentalSlot $rentalSlotHelper
|
||||
* @param \Webkul\BookingProduct\Helpers\EventTicket $EventTicketHelper
|
||||
* @param \Webkul\BookingProduct\Helpers\TableSlot $tableSlotHelper
|
||||
* @param \Webkul\BookingProduct\Helpers\DefaultSlot $defaultSlotHelper
|
||||
* @param \Webkul\BookingProduct\Helpers\AppointmentSlot $appointmentSlotHelper
|
||||
* @param \Webkul\BookingProduct\Helpers\RentalSlot $rentalSlotHelper
|
||||
* @param \Webkul\BookingProduct\Helpers\EventTicket $EventTicketHelper
|
||||
* @param \Webkul\BookingProduct\Helpers\TableSlot $tableSlotHelper
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ class BookingProductAppointmentSlotRepository extends Repository
|
|||
/**
|
||||
* Specify Model class name
|
||||
*
|
||||
* @return mixed
|
||||
* @return string
|
||||
*/
|
||||
function model()
|
||||
function model(): string
|
||||
{
|
||||
return 'Webkul\BookingProduct\Contracts\BookingProductAppointmentSlot';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ class BookingProductDefaultSlotRepository extends Repository
|
|||
/**
|
||||
* Specify Model class name
|
||||
*
|
||||
* @return mixed
|
||||
* @return string
|
||||
*/
|
||||
function model()
|
||||
function model(): string
|
||||
{
|
||||
return 'Webkul\BookingProduct\Contracts\BookingProductDefaultSlot';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,17 +11,16 @@ class BookingProductEventTicketRepository extends Repository
|
|||
/**
|
||||
* Specify Model class name
|
||||
*
|
||||
* @return mixed
|
||||
* @return string
|
||||
*/
|
||||
function model()
|
||||
function model(): string
|
||||
{
|
||||
return 'Webkul\BookingProduct\Contracts\BookingProductEventTicket';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @param \Webkul\BookingProduct\Contracts\BookingProduct $bookingProduct
|
||||
*
|
||||
* @param array $data
|
||||
* @param \Webkul\BookingProduct\Contracts\BookingProduct $bookingProduct
|
||||
* @return void
|
||||
* @throws \Prettus\Validator\Exceptions\ValidatorException
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ class BookingProductRentalSlotRepository extends Repository
|
|||
/**
|
||||
* Specify Model class name
|
||||
*
|
||||
* @return mixed
|
||||
* @return string
|
||||
*/
|
||||
function model()
|
||||
function model(): string
|
||||
{
|
||||
return 'Webkul\BookingProduct\Contracts\BookingProductRentalSlot';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
@ -48,9 +49,9 @@ class BookingProductRepository extends Repository
|
|||
/**
|
||||
* Specify Model class name
|
||||
*
|
||||
* @return mixed
|
||||
* @return string
|
||||
*/
|
||||
function model()
|
||||
function model(): string
|
||||
{
|
||||
return 'Webkul\BookingProduct\Contracts\BookingProduct';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ class BookingProductTableSlotRepository extends Repository
|
|||
/**
|
||||
* Specify Model class name
|
||||
*
|
||||
* @return mixed
|
||||
* @return string
|
||||
*/
|
||||
function model()
|
||||
function model(): string
|
||||
{
|
||||
return 'Webkul\BookingProduct\Contracts\BookingProductTableSlot';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
@ -12,9 +11,9 @@ class BookingRepository extends Repository
|
|||
/**
|
||||
* Specify Model class name
|
||||
*
|
||||
* @return mixed
|
||||
* @return string
|
||||
*/
|
||||
function model()
|
||||
function model(): string
|
||||
{
|
||||
return 'Webkul\BookingProduct\Contracts\Booking';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -239,4 +239,23 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
body {
|
||||
&.rtl {
|
||||
.booking-information {
|
||||
.icon {
|
||||
position: absolute;
|
||||
top: -4px;
|
||||
}
|
||||
|
||||
.bp-location-icon {
|
||||
right: 60px;
|
||||
}
|
||||
|
||||
.bp-slot-icon {
|
||||
right: 140px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
padding-left: 32px;
|
||||
margin-bottom: 20px;
|
||||
position: relative;
|
||||
|
||||
|
||||
.icon {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
|
|
@ -278,6 +278,19 @@ body {
|
|||
left: 80px !important;
|
||||
right: inherit !important;
|
||||
}
|
||||
|
||||
.icon {
|
||||
position: absolute;
|
||||
top: -4px;
|
||||
}
|
||||
|
||||
.bp-location-icon {
|
||||
right: 60px;
|
||||
}
|
||||
|
||||
.bp-slot-icon {
|
||||
right: 140px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -40,14 +40,14 @@ class Booking extends Virtual
|
|||
/**
|
||||
* Create a new product type instance.
|
||||
*
|
||||
* @param \Webkul\Attribute\Repositories\AttributeRepository $attributeRepository
|
||||
* @param \Webkul\Product\Repositories\ProductRepository $productRepository
|
||||
* @param \Webkul\Product\Repositories\ProductAttributeValueRepository $attributeValueRepository
|
||||
* @param \Webkul\Product\Repositories\ProductInventoryRepository $productInventoryRepository
|
||||
* @param \Webkul\Product\Repositories\ProductImageRepository $productImageRepository
|
||||
* @param \Webkul\Attribute\Repositories\AttributeRepository $attributeRepository
|
||||
* @param \Webkul\Product\Repositories\ProductRepository $productRepository
|
||||
* @param \Webkul\Product\Repositories\ProductAttributeValueRepository $attributeValueRepository
|
||||
* @param \Webkul\Product\Repositories\ProductInventoryRepository $productInventoryRepository
|
||||
* @param \Webkul\Product\Repositories\ProductImageRepository $productImageRepository
|
||||
* @param \Webkul\BookingProduct\Repositories\BookingProductRepository $bookingProductRepository
|
||||
* @param \Webkul\BookingProduct\Helpers\BookingHelper $bookingHelper
|
||||
* @param \Webkul\Product\Repositories\ProductVideoRepository $productVideoRepository
|
||||
* @param \Webkul\BookingProduct\Helpers\BookingHelper $bookingHelper
|
||||
* @param \Webkul\Product\Repositories\ProductVideoRepository $productVideoRepository
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
@ -57,8 +58,6 @@ class PageController extends Controller
|
|||
*/
|
||||
public function store()
|
||||
{
|
||||
$data = request()->all();
|
||||
|
||||
$this->validate(request(), [
|
||||
'url_key' => ['required', 'unique:cms_page_translations,url_key', new \Webkul\Core\Contracts\Validations\Slug],
|
||||
'page_title' => 'required',
|
||||
|
|
@ -66,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']);
|
||||
|
|
@ -107,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']));
|
||||
|
||||
|
|
@ -122,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);
|
||||
}
|
||||
|
|
@ -138,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;
|
||||
|
|
@ -12,9 +11,9 @@ class CmsRepository extends Repository
|
|||
/**
|
||||
* Specify Model class name
|
||||
*
|
||||
* @return mixed
|
||||
* @return string
|
||||
*/
|
||||
function model()
|
||||
function model(): string
|
||||
{
|
||||
return 'Webkul\CMS\Contracts\CmsPage';
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -53,10 +53,10 @@ class CartRule
|
|||
{
|
||||
$appliedCartRuleIds = [];
|
||||
|
||||
$this->calculateCartItemTotals($cart, $cart->items);
|
||||
$this->calculateCartItemTotals($cart);
|
||||
|
||||
foreach ($cart->items as $item) {
|
||||
$itemCartRuleIds = $this->process($cart, $item);
|
||||
$itemCartRuleIds = $this->process($item);
|
||||
|
||||
$appliedCartRuleIds = array_merge($appliedCartRuleIds, $itemCartRuleIds);
|
||||
|
||||
|
|
@ -132,41 +132,41 @@ class CartRule
|
|||
public function canProcessRule($cart, $rule): bool
|
||||
{
|
||||
if ($rule->coupon_type) {
|
||||
if (strlen($cart->coupon_code)) {
|
||||
/** @var \Webkul\CartRule\Models\CartRule $rule */
|
||||
// Laravel relation is used instead of repository for performance
|
||||
// reasons (cart_rule_coupon-relation is pre-loaded by self::getCartRuleQuery())
|
||||
$coupon = $rule->cart_rule_coupon()->where('code', $cart->coupon_code)->first();
|
||||
if (! strlen($cart->coupon_code)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** @var \Webkul\CartRule\Models\CartRule $rule */
|
||||
// Laravel relation is used instead of repository for performance
|
||||
// reasons (cart_rule_coupon-relation is pre-loaded by self::getCartRuleQuery())
|
||||
$coupon = $rule->cart_rule_coupon()->where('code', $cart->coupon_code)->first();
|
||||
|
||||
if (
|
||||
$coupon
|
||||
&& $coupon->code === $cart->coupon_code
|
||||
) {
|
||||
if (
|
||||
$coupon->usage_limit
|
||||
&& $coupon->times_used >= $coupon->usage_limit
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (
|
||||
$coupon
|
||||
&& $coupon->code === $cart->coupon_code
|
||||
$cart->customer_id
|
||||
&& $coupon->usage_per_customer
|
||||
) {
|
||||
$couponUsage = $this->cartRuleCouponUsageRepository->findOneWhere([
|
||||
'cart_rule_coupon_id' => $coupon->id,
|
||||
'customer_id' => $cart->customer_id,
|
||||
]);
|
||||
|
||||
if (
|
||||
$coupon->usage_limit
|
||||
&& $coupon->times_used >= $coupon->usage_limit
|
||||
$couponUsage
|
||||
&& $couponUsage->times_used >= $coupon->usage_per_customer
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (
|
||||
$cart->customer_id
|
||||
&& $coupon->usage_per_customer
|
||||
) {
|
||||
$couponUsage = $this->cartRuleCouponUsageRepository->findOneWhere([
|
||||
'cart_rule_coupon_id' => $coupon->id,
|
||||
'customer_id' => $cart->customer_id,
|
||||
]);
|
||||
|
||||
if (
|
||||
$couponUsage
|
||||
&& $couponUsage->times_used >= $coupon->usage_per_customer
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
|
|
@ -193,11 +193,10 @@ class CartRule
|
|||
/**
|
||||
* Cart item discount calculation process
|
||||
*
|
||||
* @param \Webkul\Checkout\Contracts\Cart $cart
|
||||
* @param \Webkul\Checkout\Models\CartItem $item
|
||||
* @return array
|
||||
*/
|
||||
public function process($cart, CartItem $item): array
|
||||
public function process(CartItem $item): array
|
||||
{
|
||||
$item->discount_percent = 0;
|
||||
$item->discount_amount = 0;
|
||||
|
|
@ -205,8 +204,8 @@ class CartRule
|
|||
|
||||
$appliedRuleIds = [];
|
||||
|
||||
foreach ($rules = $this->getCartRules($cart) as $rule) {
|
||||
if (! $this->canProcessRule($cart, $rule)) {
|
||||
foreach ($rules = $this->getCartRules($item->cart) as $rule) {
|
||||
if (! $this->canProcessRule($item->cart, $rule)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -319,7 +318,7 @@ class CartRule
|
|||
* Cart shipping discount calculation process
|
||||
*
|
||||
* @param \Webkul\Checkout\Contracts\Cart $cart
|
||||
* @return void
|
||||
* @return self|void
|
||||
*/
|
||||
public function processShippingDiscount($cart)
|
||||
{
|
||||
|
|
@ -418,9 +417,7 @@ class CartRule
|
|||
$appliedRuleIds = [];
|
||||
|
||||
foreach ($cart->items->all() as $item) {
|
||||
|
||||
foreach ($this->getCartRules($cart) as $rule) {
|
||||
|
||||
if (! $this->canProcessRule($cart, $rule)) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -466,36 +463,37 @@ class CartRule
|
|||
* Calculate cart item totals for each rule
|
||||
*
|
||||
* @param \Webkul\Checkout\Contracts\Cart $cart
|
||||
* @param \Illuminate\Support\Collecton $items
|
||||
* @return \Webkul\Rule\Helpers\Validator
|
||||
* @return array|void
|
||||
*/
|
||||
public function calculateCartItemTotals($cart, $items)
|
||||
public function calculateCartItemTotals($cart)
|
||||
{
|
||||
foreach ($this->getCartRules($cart) as $rule) {
|
||||
if ($rule->action_type == 'cart_fixed') {
|
||||
$totalPrice = $totalBasePrice = $validCount = 0;
|
||||
if ($rule->action_type != 'cart_fixed') {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($items as $item) {
|
||||
if (! $this->canProcessRule($cart, $rule)) {
|
||||
continue;
|
||||
}
|
||||
$totalPrice = $totalBasePrice = $validCount = 0;
|
||||
|
||||
if (! $this->validator->validate($rule, $item)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$quantity = $rule->discount_quantity ? min($item->quantity, $rule->discount_quantity) : $item->quantity;
|
||||
|
||||
$totalBasePrice += $item->base_price * $quantity;
|
||||
|
||||
$validCount++;
|
||||
foreach ($cart->items as $item) {
|
||||
if (! $this->canProcessRule($cart, $rule)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->itemTotals[$rule->id] = [
|
||||
'base_total_price' => $totalBasePrice,
|
||||
'total_items' => $validCount,
|
||||
];
|
||||
if (! $this->validator->validate($rule, $item)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$quantity = $rule->discount_quantity ? min($item->quantity, $rule->discount_quantity) : $item->quantity;
|
||||
|
||||
$totalBasePrice += $item->base_price * $quantity;
|
||||
|
||||
$validCount++;
|
||||
}
|
||||
|
||||
$this->itemTotals[$rule->id] = [
|
||||
'base_total_price' => $totalBasePrice,
|
||||
'total_items' => $validCount,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -546,9 +544,8 @@ class CartRule
|
|||
}
|
||||
|
||||
/**
|
||||
* @param $customerGroupId
|
||||
* @param $channelId
|
||||
*
|
||||
* @param integer $customerGroupId
|
||||
* @param integer $channelId
|
||||
* @return \Illuminate\Database\Eloquent\Collection
|
||||
*/
|
||||
public function getCartRuleQuery($customerGroupId, $channelId): \Illuminate\Database\Eloquent\Collection
|
||||
|
|
|
|||
|
|
@ -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,9 +100,11 @@ class CartRuleController extends Controller
|
|||
public function store(CartRuleRequest $cartRuleRequest)
|
||||
{
|
||||
try {
|
||||
$data = $cartRuleRequest->all();
|
||||
Event::dispatch('promotions.cart_rule.create.before');
|
||||
|
||||
$this->cartRuleRepository->create($data);
|
||||
$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']));
|
||||
|
||||
|
|
@ -152,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']);
|
||||
|
|
@ -177,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) {}
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue