diff --git a/app/Http/Controllers/admin/product/ProductCategoryController.php b/app/Http/Controllers/admin/product/ProductCategoryController.php
index b8f1846..88446c2 100644
--- a/app/Http/Controllers/admin/product/ProductCategoryController.php
+++ b/app/Http/Controllers/admin/product/ProductCategoryController.php
@@ -59,6 +59,23 @@ class ProductCategoryController extends Controller
return redirect()->route('products.group.index')->with('success', 'Delete Group Success');
}
+ public function trash()
+ {
+ return view('administrator.pages.product.categories.trash');
+ }
+
+ public function restore(int $id)
+ {
+ $this->productCategoryService->restore($id);
+ return redirect()->route('products.group.trash')->with('success', 'Restore Group Success');
+ }
+
+ public function forceDelete(int $id)
+ {
+ $this->productCategoryService->forceDelete($id);
+ return redirect()->route('products.group.trash')->with('success', 'Force Delete Group Success');
+ }
+
public function datatable(Request $request)
{
$query = $this->productCategoryRepository->filter(
@@ -72,7 +89,10 @@ class ProductCategoryController extends Controller
return DataTables::eloquent($query)
->addColumn(
'action',
- function ($d) {
+ function ($d) use ($request) {
+ if ($request->has('trashed') && $request->trashed == 1) {
+ return view('administrator.pages.product.categories.datatable.action_trash', ['row' => $d])->render();
+ }
return view('administrator.pages.product.categories.datatable.action', ['row' => $d])->render();
}
)
diff --git a/app/Http/Services/Admin/ProductCategory/ProductCategoryService.php b/app/Http/Services/Admin/ProductCategory/ProductCategoryService.php
index fd3f615..ebbf67f 100644
--- a/app/Http/Services/Admin/ProductCategory/ProductCategoryService.php
+++ b/app/Http/Services/Admin/ProductCategory/ProductCategoryService.php
@@ -29,4 +29,14 @@ class ProductCategoryService implements ProductCategoryServiceInterface
{
return $this->repository->delete($id);
}
+
+ public function restore(int $id)
+ {
+ return $this->repository->restore($id);
+ }
+
+ public function forceDelete(int $id)
+ {
+ return $this->repository->forceDelete($id);
+ }
}
\ No newline at end of file
diff --git a/app/Http/Services/Admin/ProductCategory/ProductCategoryServiceInterface.php b/app/Http/Services/Admin/ProductCategory/ProductCategoryServiceInterface.php
index d96b0f2..e513ab9 100644
--- a/app/Http/Services/Admin/ProductCategory/ProductCategoryServiceInterface.php
+++ b/app/Http/Services/Admin/ProductCategory/ProductCategoryServiceInterface.php
@@ -6,4 +6,8 @@ interface ProductCategoryServiceInterface {
public function store(array $data);
public function update(int $id, array $data);
public function delete(int $id);
+
+ public function restore(int $id);
+
+ public function forceDelete(int $id);
}
\ No newline at end of file
diff --git a/app/Repositories/Admin/ProductCategory/ProductCategoryRepository.php b/app/Repositories/Admin/ProductCategory/ProductCategoryRepository.php
index a0c45e2..e42b8d8 100644
--- a/app/Repositories/Admin/ProductCategory/ProductCategoryRepository.php
+++ b/app/Repositories/Admin/ProductCategory/ProductCategoryRepository.php
@@ -40,6 +40,10 @@ class ProductCategoryRepository extends BaseRepository implements ProductCategor
->select($select)
->with($relationships);
+ if (!empty($data['trashed'])) {
+ $query->onlyTrashed();
+ }
+
// if (!empty($data['vcenter_id'])) {
// $query->where('vcenter_id', $data['vcenter_id']);
// }
@@ -60,4 +64,21 @@ class ProductCategoryRepository extends BaseRepository implements ProductCategor
return $query->get();
}
+ public function restore(int $id)
+ {
+ $item = $this->model->withTrashed()->find($id);
+ if ($item) {
+ return $item->restore();
+ }
+ return false;
+ }
+
+ public function forceDelete(int $id)
+ {
+ $item = $this->model->withTrashed()->find($id);
+ if ($item) {
+ return $item->forceDelete();
+ }
+ return false;
+ }
}
diff --git a/app/Repositories/Admin/ProductCategory/ProductCategoryRepositoryInterface.php b/app/Repositories/Admin/ProductCategory/ProductCategoryRepositoryInterface.php
index e5d00a1..c04275d 100644
--- a/app/Repositories/Admin/ProductCategory/ProductCategoryRepositoryInterface.php
+++ b/app/Repositories/Admin/ProductCategory/ProductCategoryRepositoryInterface.php
@@ -13,4 +13,8 @@ interface ProductCategoryRepositoryInterface extends BaseRepositoryInterface
array $select = ['*'],
bool $returnQuery = false
);
+
+ public function restore(int $id);
+
+ public function forceDelete(int $id);
}
diff --git a/resources/views/administrator/pages/block/product/btn.blade.php b/resources/views/administrator/pages/block/product/btn.blade.php
index a65a43c..20f4609 100644
--- a/resources/views/administrator/pages/block/product/btn.blade.php
+++ b/resources/views/administrator/pages/block/product/btn.blade.php
@@ -1,6 +1,9 @@
@if(auth()->guard('admins')->user()->can("manager product"))
-