This commit is contained in:
jitendra 2019-10-14 12:22:58 +05:30
parent 707ff1207c
commit b24c2507e8
3 changed files with 25 additions and 21 deletions

View File

@ -138,14 +138,19 @@
<accordian :title="'{{ __('admin::app.catalog.categories.filterable-attributes') }}'" :active="true">
<div slot="body">
<?php $selectedaAtributes = old('attributes') ?? [] ?>
<div class="control-group" :class="[errors.has('attributes[]') ? 'has-error' : '']">
<label for="attributes" class="required">{{ __('admin::app.catalog.categories.attributes') }}</label>
<select class="control" name="attributes[]" v-validate="'required'" data-vv-as="&quot;{{ __('admin::app.catalog.categories.attributes') }}&quot;" multiple>
@foreach ($attributes as $attribute)
<option value="{{ $attribute->id }}">
<option value="{{ $attribute->id }}" {{ in_array($attribute->id, $selectedaAtributes) ? 'selected' : ''}}>
{{ $attribute->name ? $attribute->name : $attribute->admin_name }}
</option>
@endforeach
</select>
<span class="control-error" v-if="errors.has('attributes[]')">
@{{ errors.first('attributes[]') }}

View File

@ -150,14 +150,19 @@
<accordian :title="'{{ __('admin::app.catalog.categories.filterable-attributes') }}'" :active="true">
<div slot="body">
<?php $selectedaAtributes = old('attributes') ?? $category->filterableAttributes->pluck('id')->toArray() ?>
<div class="control-group" :class="[errors.has('attributes[]') ? 'has-error' : '']">
<label for="attributes" class="required">{{ __('admin::app.catalog.categories.attributes') }}</label>
<select class="control" name="attributes[]" v-validate="'required'" data-vv-as="&quot;{{ __('admin::app.catalog.categories.attributes') }}&quot;" multiple>
@foreach ($attributes as $attribute)
<option value="{{ $attribute->id }}" {{ in_array($attribute->id, $category->filterableAttributes->pluck('id')->toArray()) ? 'selected' : ''}}>
<option value="{{ $attribute->id }}" {{ in_array($attribute->id, $selectedaAtributes) ? 'selected' : ''}}>
{{ $attribute->name ? $attribute->name : $attribute->admin_name }}
</option>
@endforeach
</select>
<span class="control-error" v-if="errors.has('attributes[]')">
@{{ errors.first('attributes[]') }}

View File

@ -137,29 +137,23 @@ class CategoryController extends Controller
*/
public function update($id)
{
try {
$locale = request()->get('locale') ?: app()->getLocale();
$locale = request()->get('locale') ?: app()->getLocale();
$this->validate(request(), [
$locale . '.slug' => ['required', new \Webkul\Core\Contracts\Validations\Slug, function ($attribute, $value, $fail) use ($id) {
if (! $this->category->isSlugUnique($id, $value)) {
$fail(trans('admin::app.response.already-taken', ['name' => 'Category']));
}
}],
$locale . '.name' => 'required',
'image.*' => 'mimes:jpeg,jpg,bmp,png'
]);
$this->validate(request(), [
$locale . '.slug' => ['required', new \Webkul\Core\Contracts\Validations\Slug, function ($attribute, $value, $fail) use ($id) {
if (! $this->categoryRepository->isSlugUnique($id, $value)) {
$fail(trans('admin::app.response.already-taken', ['name' => 'Category']));
}
}],
$locale . '.name' => 'required',
'image.*' => 'mimes:jpeg,jpg,bmp,png'
]);
$this->category->update(request()->all(), $id);
$this->categoryRepository->update(request()->all(), $id);
session()->flash('success', trans('admin::app.response.update-success', ['name' => 'Category']));
session()->flash('success', trans('admin::app.response.update-success', ['name' => 'Category']));
return redirect()->route($this->_config['redirect']);
} catch(\Exception $e) {
session()->flash('error', trans($e->getMessage()));
return redirect()->back();
}
return redirect()->route($this->_config['redirect']);
}
/**