From 62ca618368ad0557dc4cac026f974293f1fd89f9 Mon Sep 17 00:00:00 2001 From: bamo100 Date: Sat, 24 Aug 2024 20:40:27 +0100 Subject: [PATCH] deleteplan --- .../Controllers/BillingPlanController.php | 26 ++++++++++++++++++- routes/api.php | 1 + 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/BillingPlanController.php b/app/Http/Controllers/BillingPlanController.php index 62018f88..95725d8e 100644 --- a/app/Http/Controllers/BillingPlanController.php +++ b/app/Http/Controllers/BillingPlanController.php @@ -111,6 +111,30 @@ public function update(Request $request, string $id) */ public function destroy(string $id) { - // + $plans = SubscriptionPlan::find($id); + + if (!$plans) { + return response()->json([ + 'status_code' => 404, + 'error' => 'Not Found', + 'message' => 'Plan not found' + ], 404); + } + + try { + $plans->delete(); + + // Return success response + return response()->json([ + 'data' => true, + 'status_code' => 200, + 'message' => 'Plan deleted successfully' + ], 200); + } catch (\Exception $e) { + return response()->json([ + 'status' => 500, + 'message' => 'Internal server error' + ], 500); + } } } diff --git a/routes/api.php b/routes/api.php index 37aadf57..5c1c36ee 100755 --- a/routes/api.php +++ b/routes/api.php @@ -112,6 +112,7 @@ Route::get('/products/{product_id}', [ProductController::class, 'show']); Route::get('/billing-plans', [BillingPlanController::class, 'index']); Route::get('/billing-plans/{id}', [BillingPlanController::class, 'getBillingPlan']); + Route::delete('/billing-plans/{id}', [BillingPlanController::class, 'destroy']); Route::get('/payments/paystack/{organisation_id}/verify/{id}', [PaymentController::class, 'handlePaystackCallback']); Route::get('/payments/flutterwave/{organisation_id}/verify/{id}', [PaymentController::class, 'handleFlutterwaveCallback']); Route::post('/languages', [LanguageController::class, 'create']);