Fixed Issue #551 - Root Category Getting Deleted

This commit is contained in:
Prashant Singh 2019-02-06 16:28:00 +05:30
parent 437548f533
commit de6507ff08
3 changed files with 11 additions and 6 deletions

View File

@ -763,6 +763,7 @@ return [
'attribute-error' => ':name is used in configurable products.',
'attribute-product-error' => ':name is used in products.',
'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'
],
];

View File

@ -137,11 +137,15 @@ class CategoryController extends Controller
{
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();
}
@ -154,7 +158,7 @@ class CategoryController extends Controller
public function massDestroy() {
$suppressFlash = false;
if (request()->isMethod('delete')) {
if (request()->isMethod('delete') || request()->isMethod('post')) {
$indexes = explode(',', request()->input('indexes'));
foreach ($indexes as $key => $value) {

View File

@ -46,7 +46,7 @@ class SessionController extends Controller
return redirect()->route('admin.dashboard.index');
} else {
session()->put('url.intended', url()->previous());
return view($this->_config['view']);
}