Issue #1250 fixed
This commit is contained in:
parent
707ff1207c
commit
b24c2507e8
|
|
@ -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=""{{ __('admin::app.catalog.categories.attributes') }}"" 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[]') }}
|
||||
|
|
|
|||
|
|
@ -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=""{{ __('admin::app.catalog.categories.attributes') }}"" 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[]') }}
|
||||
|
|
|
|||
|
|
@ -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']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue