Fixed Issue #551 - Root Category Getting Deleted
This commit is contained in:
parent
437548f533
commit
de6507ff08
|
|
@ -763,6 +763,7 @@ return [
|
||||||
'attribute-error' => ':name is used in configurable products.',
|
'attribute-error' => ':name is used in configurable products.',
|
||||||
'attribute-product-error' => ':name is used in products.',
|
'attribute-product-error' => ':name is used in products.',
|
||||||
'customer-associate' => ':name can not be deleted because customer is associated with this group.',
|
'customer-associate' => ':name can not be deleted because customer is associated with this group.',
|
||||||
'currency-delete-error' => 'This currency is set as channel base currency so it can not be deleted.'
|
'currency-delete-error' => 'This currency is set as channel base currency so it can not be deleted.',
|
||||||
|
'delete-category-root' => 'Cannot delete the root category'
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
@ -137,11 +137,15 @@ class CategoryController extends Controller
|
||||||
{
|
{
|
||||||
Event::fire('catalog.category.delete.before', $id);
|
Event::fire('catalog.category.delete.before', $id);
|
||||||
|
|
||||||
$this->category->delete($id);
|
if(strtolower($this->category->find($id)->name) == "root") {
|
||||||
|
session()->flash('warning', trans('admin::app.response.delete-category-root', ['name' => 'Category']));
|
||||||
|
} else {
|
||||||
|
session()->flash('success', trans('admin::app.response.delete-success', ['name' => 'Category']));
|
||||||
|
|
||||||
Event::fire('catalog.category.delete.after', $id);
|
$this->category->delete($id);
|
||||||
|
|
||||||
session()->flash('success', trans('admin::app.response.delete-success', ['name' => 'Category']));
|
Event::fire('catalog.category.delete.after', $id);
|
||||||
|
}
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
@ -154,7 +158,7 @@ class CategoryController extends Controller
|
||||||
public function massDestroy() {
|
public function massDestroy() {
|
||||||
$suppressFlash = false;
|
$suppressFlash = false;
|
||||||
|
|
||||||
if (request()->isMethod('delete')) {
|
if (request()->isMethod('delete') || request()->isMethod('post')) {
|
||||||
$indexes = explode(',', request()->input('indexes'));
|
$indexes = explode(',', request()->input('indexes'));
|
||||||
|
|
||||||
foreach ($indexes as $key => $value) {
|
foreach ($indexes as $key => $value) {
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ class SessionController extends Controller
|
||||||
return redirect()->route('admin.dashboard.index');
|
return redirect()->route('admin.dashboard.index');
|
||||||
} else {
|
} else {
|
||||||
session()->put('url.intended', url()->previous());
|
session()->put('url.intended', url()->previous());
|
||||||
|
|
||||||
return view($this->_config['view']);
|
return view($this->_config['view']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue