Skip to content

Commit 785a9e2

Browse files
committed
Add restore functionality for trashed products in ProductController
This commit introduces a new method, 'restoreProduct', to the ProductController, allowing products to be restored from the trash state. Additionally, the API routes are updated to include this new functionality, enhancing the product management capabilities by providing a way to recover previously trashed products.
1 parent 994e7f3 commit 785a9e2

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

app/Http/Controllers/Seller/ProductController.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,15 @@ public function destroy(string $id)
228228
public function putInTrash($id){
229229
$product=Product::find($id);
230230
$product->is_trashed=1;
231-
$product->status=0;
231+
232232
$product->save();
233233
return response()->json(['message' => 'Product put in trash successfully']);
234234
}
235+
236+
public function restoreProduct($id){
237+
$product=Product::find($id);
238+
$product->is_trashed=0;
239+
$product->save();
240+
return response()->json(['message' => 'Product restore successfully']);
241+
}
235242
}

routes/api.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,8 @@
183183
Route::post("/boost/shop",[BoostShopController::class,'boost']);
184184

185185
Route::post('/put/in/trash/{id}',[ProductController::class,'putInTrash']);
186-
Route::get('/seller/products/trash',[ProductController::class,'productListOfTrash']);
187-
186+
Route::get('/trash/products',[ProductController::class,'productListOfTrash']);
187+
Route::post("/restore/product/{id}",[ProductController::class,'restoreProduct']);
188188
// Routes pour la gestion des commandes du vendeur
189189
Route::get('/seller/orders', [OrderListController::class, 'listOrders']);
190190
Route::get('/seller/orders/shop/{shopId}', [OrderListController::class, 'listOrdersByShop']);

0 commit comments

Comments
 (0)