completed clean sub categories

This commit is contained in:
vedatakd 2021-03-05 17:44:27 +03:00
parent ee69934c3d
commit cd9a416ff1
2 changed files with 12 additions and 16 deletions

View File

@ -117,7 +117,7 @@ class CategoryRepository extends EntryRepository implements CategoryRepositoryIn
public function getDeletedCategories() public function getDeletedCategories()
{ {
return $this->newQuery()->whereNotNull('deleted_at')->get(); return $this->model->withTrashed()->newQuery()->whereNotNull('deleted_at')->get();
} }
public function getMainAndSubCats() public function getMainAndSubCats()

View File

@ -213,21 +213,17 @@ class CategoryController extends AdminController
public function cleanSubCategories() public function cleanSubCategories()
{ {
// $cats = $this->categoryRepository->getDeletedCategories(); $sub_c = 1;
// for ($i = 0; $i <= $sub_c; $i++) {
// $delete_category_keys = $cats->pluck('id'); $cats = $this->categoryRepository->getDeletedCategories();
// $delete_category_keys = $cats->pluck('id')->all();
// dd($delete_category_keys); $query_delete = $this->categoryRepository->newQuery()->whereIn('parent_category_id', $delete_category_keys);
// if ($query_delete->count()) {
// foreach ($cats as $cat) { $query_delete->delete();
// $parentCatId = $cat->parent_category_id; $sub_c++;
// $parentCat = $this->categoryRepository->find($parentCatId); }
// if (is_null($parentCat) && !is_null($parentCatId)) { }
// $this->categoryEntryTranslationsModel->where('entry_id', $cat->id)->delete();
// //Todo Sub Categories
// $deletedCatsCount++;
// }
// }
return redirect('admin/cats'); return redirect('admin/cats');
} }