Merge pull request #5447 from devansh-webkul/attribute-issues

Attribute Issue Fixed #5443
This commit is contained in:
Glenn Hermans 2021-12-20 11:59:13 +01:00 committed by GitHub
commit 40c2d494f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 19 deletions

View File

@ -158,35 +158,25 @@ class AttributeController extends Controller
*/
public function massDestroy()
{
$suppressFlash = false;
if (request()->isMethod('post')) {
$indexes = explode(',', request()->input('indexes'));
foreach ($indexes as $key => $value) {
$attribute = $this->attributeRepository->find($value);
foreach ($indexes as $index) {
$attribute = $this->attributeRepository->find($index);
try {
if ($attribute->is_user_defined) {
$suppressFlash = true;
if (! $attribute->is_user_defined) {
session()->flash('error', trans('admin::app.response.user-define-error', ['name' => 'Attribute']));
$this->attributeRepository->delete($value);
}
} catch (\Exception $e) {
report($e);
$suppressFlash = true;
continue;
return redirect()->back();
}
}
if ($suppressFlash) {
session()->flash('success', trans('admin::app.datagrid.mass-ops.delete-success', ['resource' => 'attributes']));
} else {
session()->flash('error', trans('admin::app.response.user-define-error', ['name' => 'Attribute']));
foreach ($indexes as $index) {
$this->attributeRepository->delete($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'));