updated package of customer group catalog

This commit is contained in:
Prashant Singh 2019-06-24 11:22:06 +05:30
parent df2e63a12a
commit 714d9deed1
5 changed files with 62 additions and 25 deletions

View File

@ -40,18 +40,39 @@ class CategoryRepository extends BaseCategoryRepository
{
static $categories = [];
if(array_key_exists($id, $categories))
if (array_key_exists($id, $categories))
return $categories[$id];
$customer = auth()->guard(request()->has('token') ? 'api' : 'customer')->user();
$categoryIds = [];
$categoryShowId = [];
if (! $customer) {
$categoryIds = app('Webkul\CustomerGroupCatalog\Repositories\CustomerGroupRepository')->findOneByField('code', 'guest')->categories()->pluck('id');
} else {
if ($customer->group) {
$categoryIds = app('Webkul\CustomerGroupCatalog\Repositories\CustomerGroupRepository')->find($customer->group->id)->categories()->pluck('id');
$categoryIds = app('Webkul\CustomerGroupCatalog\Repositories\CustomerGroupRepository')->find($customer->group->id)->categories()->get();
$parentIds = app('Webkul\CustomerGroupCatalog\Repositories\CustomerGroupRepository')->find($customer->group->id)->categories()->pluck('parent_id')->toArray();
if (in_array(NULL, $parentIds)) {
foreach ($categoryIds as $categoryId) {
foreach ($parentIds as $parentId) {
if ($categoryId->parent_id == $parentId) {
$categoryShowId[] = $categoryId->id;
}
}
}
if (count($categoryShowId) > 0) {
$categoryIds = array_unique($categoryShowId);
} else {
$categoryIds = [];
}
} else {
$categoryIds = [];
}
}
}
@ -59,12 +80,14 @@ class CategoryRepository extends BaseCategoryRepository
$categories[$id] = $id
? $this->model::orderBy('position', 'ASC')->where('status', 1)->whereIn('id', $categoryIds)->descendantsOf($id)->toTree()
: $this->model::orderBy('position', 'ASC')->where('status', 1)->whereIn('id', $categoryIds)->get()->toTree();
} else {
$categories[$id] = $id
? $this->model::orderBy('position', 'ASC')->where('status', 1)->descendantsOf($id)->toTree()
: $this->model::orderBy('position', 'ASC')->where('status', 1)->get()->toTree();
}
return $categories[$id];
return $categories[$id];
} else {
// $categories[$id] = $id
// ? $this->model::orderBy('position', 'ASC')->where('status', 1)->descendantsOf($id)->toTree()
// : $this->model::orderBy('position', 'ASC')->where('status', 1)->get()->toTree();
return [];
}
}
}

View File

@ -7,7 +7,8 @@ return [
'linked-product-categories' => 'Linked Products and Categories',
'categories' => 'Categories',
'products' => 'Products',
'search-hint' => 'Start typing name'
'search-hint' => 'Start typing name',
'no-result-found' => 'Categories not found with same name.'
]
]
];

View File

@ -12,7 +12,7 @@
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="history.length > 1 ? history.go(-1) : window.location = '{{ url('/admin/dashboard') }}';"></i>
{{ __('admin::app.customers.groups.add-title') }}
</h1>
</div>
@ -31,6 +31,12 @@
<accordian :title="'{{ __('customergroupcatalog::app.customers.groups.general') }}'" :active="true">
<div slot="body">
<div class="control-group" :class="[errors.has('code') ? 'has-error' : '']">
<label for="code" class="required">{{ __('admin::app.customers.groups.code') }}</label>
<input v-validate="'required'" class="control" id="code" name="code" data-vv-as="&quot;{{ __('admin::app.customers.groups.code') }}&quot;" v-code/>
<span class="control-error" v-if="errors.has('code')">@{{ errors.first('code') }}</span>
</div>
<div class="control-group" :class="[errors.has('name') ? 'has-error' : '']">
<label for="name" class="required">
{{ __('admin::app.customers.groups.name') }}
@ -74,7 +80,7 @@
</li>
<li v-if='! searched_results[key].length && search_terms[key].length && ! is_searching[key]'>
{{ __('admin::app.catalog.products.no-result-found') }}
{{ __('customergroupcatalog::app.customers.groups.no-result-found') }}
</li>
<li v-if="is_searching[key] && search_terms[key].length">
@ -116,7 +122,7 @@
saved_results: {
products: [],
categories: [],
},
@ -142,7 +148,7 @@
'products': "{{ __('customergroupcatalog::app.customers.groups.products') }}",
'categories': "{{ __('customergroupcatalog::app.customers.groups.categories') }}",
}
}
}
},
@ -185,7 +191,7 @@
return;
}
this.$http.get ("{{ route('admin.customer_group_catalog.search.catalog') }}", {params: {query: this.search_terms[key], type: key}})
.then (function(response) {
for (var key1 in this_this.saved_results[key]) {

View File

@ -12,7 +12,7 @@
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="history.length > 1 ? history.go(-1) : window.location = '{{ url('/admin/dashboard') }}';"></i>
{{ __('admin::app.customers.groups.edit-title') }}
</h1>
</div>
@ -34,6 +34,13 @@
<accordian :title="'{{ __('customergroupcatalog::app.customers.groups.general') }}'" :active="true">
<div slot="body">
<div class="control-group" :class="[errors.has('code') ? 'has-error' : '']">
<label for="code" class="required">{{ __('admin::app.customers.groups.code') }}</label>
<input type="text" v-validate="'required'" class="control" id="code" name="code" data-vv-as="&quot;{{ __('admin::app.customers.groups.code') }}&quot;" value="{{ $group->code }}" disabled="disabled"/>
<input type="hidden" name="code" value="{{ $group->code }}"/>
<span class="control-error" v-if="errors.has('code')">@{{ errors.first('code') }}</span>
</div>
<div class="control-group" :class="[errors.has('name') ? 'has-error' : '']">
<label for="name" class="required">
{{ __('admin::app.customers.groups.name') }}
@ -43,7 +50,7 @@
</div>
</div>
</accordian>
<accordian :title="'{{ __('customergroupcatalog::app.customers.groups.linked-product-categories') }}'">
@ -76,7 +83,7 @@
</li>
<li v-if='! searched_results[key].length && search_terms[key].length && ! is_searching[key]'>
{{ __('admin::app.catalog.products.no-result-found') }}
{{ __('customergroupcatalog::app.customers.groups.no-result-found') }}
</li>
<li v-if="is_searching[key] && search_terms[key].length">
@ -116,13 +123,13 @@
saved_results: {
products: [],
categories: []
},
linked_results: {
products: @json(app('Webkul\CustomerGroupCatalog\Repositories\CustomerGroupRepository')->getProducts($group)),
categories: @json(app('Webkul\CustomerGroupCatalog\Repositories\CustomerGroupRepository')->getCategories($group))
},
@ -148,7 +155,7 @@
products: "{{ __('customergroupcatalog::app.customers.groups.products') }}",
categories: "{{ __('customergroupcatalog::app.customers.groups.categories') }}"
}
}
}
},
@ -201,7 +208,7 @@
return;
}
this.$http.get ("{{ route('admin.customer_group_catalog.search.catalog') }}", {params: {query: this.search_terms[key], type: key}})
.then (function(response) {
for (var key1 in this_this.saved_results[key]) {

View File

@ -227,14 +227,14 @@ class StripeConnectController extends Controller
$stripeCard = json_decode($stripeCard);
if(isset($stripeCard->stripeToken)) {
if (isset($stripeCard->stripeToken)) {
$stripeToken = $stripeCard->stripeToken;
} else if(isset($stripeCard->useSavedCard)) {
} else if (isset($stripeCard->useSavedCard)) {
$cardId = $stripeCard->savedCardId;
$card = $this->stripeRepository->findOneByField('id', $cardId);
if($card->need_new_token) {
if ($card->need_new_token) {
$result = false;
} else {
$stripeToken = $card->token;