diff --git a/addons/default/visiosoft/cats-module/resources/lang/en/button.php b/addons/default/visiosoft/cats-module/resources/lang/en/button.php index bf027d9ac..0388476ea 100644 --- a/addons/default/visiosoft/cats-module/resources/lang/en/button.php +++ b/addons/default/visiosoft/cats-module/resources/lang/en/button.php @@ -5,4 +5,5 @@ return [ 'add_sub_category' => 'Add Sub Category', 'sub_category' => 'Show Sub Category', 'new_placeholderforsearch' => 'New Placeholderforsearch', + 'convert_main' => 'Convert Main Category', ]; diff --git a/addons/default/visiosoft/cats-module/resources/lang/tr/button.php b/addons/default/visiosoft/cats-module/resources/lang/tr/button.php index ea0bb9b2b..eb54ff497 100644 --- a/addons/default/visiosoft/cats-module/resources/lang/tr/button.php +++ b/addons/default/visiosoft/cats-module/resources/lang/tr/button.php @@ -5,4 +5,5 @@ return [ 'add_sub_category' => 'Alt Kategori Ekle', 'sub_category' => 'Alt Kategoriyi Göster', 'new_placeholderforsearch' => 'Arama için Yeni Yer Tutucu', + 'convert_main' => 'Ana Kategori Yap', ]; diff --git a/addons/default/visiosoft/cats-module/src/Category/Table/CategoryTableButtons.php b/addons/default/visiosoft/cats-module/src/Category/Table/CategoryTableButtons.php index 4bdc6f1a5..72c9b85c4 100644 --- a/addons/default/visiosoft/cats-module/src/Category/Table/CategoryTableButtons.php +++ b/addons/default/visiosoft/cats-module/src/Category/Table/CategoryTableButtons.php @@ -21,12 +21,21 @@ class CategoryTableButtons 'type' => 'success', 'href' => '/admin/cats?cat={entry.id}' ], + 'convert_main' => [ + 'icon' => 'refresh', + 'class' => function () { + if (!request('cat')) { + return 'hidden'; + } + }, + 'type' => 'info', + 'href' => '/admin/cats/convert-main/{entry.id}' + ], 'delete' => [ 'icon' => 'fa fa-trash', 'type' => 'danger', - 'href' => function(EntryInterface $entry) - { - return route('visiosoft.module.cats::admin.delete_category', ['id' => $entry->getId()])."?parent=".$entry->parent_category_id; + 'href' => function (EntryInterface $entry) { + return route('visiosoft.module.cats::admin.delete_category', ['id' => $entry->getId()]) . "?parent=" . $entry->parent_category_id; } ] ]); diff --git a/addons/default/visiosoft/cats-module/src/CatsModuleServiceProvider.php b/addons/default/visiosoft/cats-module/src/CatsModuleServiceProvider.php index fa5d356b3..fde6e60b2 100644 --- a/addons/default/visiosoft/cats-module/src/CatsModuleServiceProvider.php +++ b/addons/default/visiosoft/cats-module/src/CatsModuleServiceProvider.php @@ -40,6 +40,7 @@ class CatsModuleServiceProvider extends AddonServiceProvider 'as' => 'visiosoft.module.cats::import', 'uses' => 'Visiosoft\CatsModule\Http\Controller\Admin\CategoryController@import', ], + 'admin/cats/convert-main/{id}' => 'Visiosoft\CatsModule\Http\Controller\Admin\CategoryController@convertMain', 'admin/cats/export' => [ 'as' => 'visiosoft.module.cats::export', 'uses' => 'Visiosoft\CatsModule\Http\Controller\Admin\CategoryController@export', diff --git a/addons/default/visiosoft/cats-module/src/Http/Controller/Admin/CategoryController.php b/addons/default/visiosoft/cats-module/src/Http/Controller/Admin/CategoryController.php index 76d329fe3..6e44cd6ed 100644 --- a/addons/default/visiosoft/cats-module/src/Http/Controller/Admin/CategoryController.php +++ b/addons/default/visiosoft/cats-module/src/Http/Controller/Admin/CategoryController.php @@ -273,7 +273,7 @@ class CategoryController extends AdminController $file = $uploader->upload($file, $folder); - $url = route('anomaly.module.files::files.view',['folder' => $folder->slug,'name' => $file->name]); + $url = route('anomaly.module.files::files.view', ['folder' => $folder->slug, 'name' => $file->name]); $category->setCategoryIconUrl($url); } catch (\Exception $exception) { @@ -338,4 +338,14 @@ class CategoryController extends AdminController ]; } } + + public function convertMain($id) + { + if ($category = $this->categoryRepository->find($id)) { + $category->update(['parent_category_id' => null]); + + $this->messages->success(trans('streams::message.edit_success', ['name' => trans('visiosoft.module.cats::addon.title')])); + return redirect('admin/cats'); + } + } }