From 990ff223767e2152ffb7f7da3e2486780ee8f271 Mon Sep 17 00:00:00 2001 From: "p.belezov" Date: Mon, 13 Jan 2025 15:48:48 +0800 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20?= =?UTF-8?q?=D0=BE=D1=82=D0=BC=D0=B5=D0=BD=D1=83=20=D0=B1=D1=80=D0=BE=D0=BD?= =?UTF-8?q?=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F,=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=B4=D0=BE=D0=B3=D0=BD=D0=B0=D0=BB=20=D0=BF=D0=BE=D0=B4?= =?UTF-8?q?=20=D0=BC=D0=BE=D0=B1=D0=B8=D0=BB=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/WishesController.php | 11 +++++ resources/store/wish.js | 19 ++++++++ resources/views/Public.vue | 18 +++++--- .../views/PublicWishlist/ShowWhishlist.vue | 29 ++++++++----- resources/views/Wishlist/Wishlist.vue | 43 ++++--------------- routes/api.php | 1 + 6 files changed, 72 insertions(+), 49 deletions(-) diff --git a/app/Http/Controllers/WishesController.php b/app/Http/Controllers/WishesController.php index f7a0828..984ef1b 100644 --- a/app/Http/Controllers/WishesController.php +++ b/app/Http/Controllers/WishesController.php @@ -99,4 +99,15 @@ class WishesController extends Controller $wish->save(); return response()->json($wish, 200); } + + public function unbook(Request $request) + { + $request->validate([ + 'id' => 'required|exists:wishes,id' + ]); + $wish = Wish::find($request->get('id')); + $wish->book_user_id = null; + $wish->save(); + return response()->json($wish, 200); + } } diff --git a/resources/store/wish.js b/resources/store/wish.js index 5fcbabe..5291ce0 100644 --- a/resources/store/wish.js +++ b/resources/store/wish.js @@ -103,6 +103,25 @@ export const useWishStore = defineStore('wish', { result = error; }); return result; + }, + async unbook(id, token){ + let result = null; + await axios.post(`/api/wish/unbook`, + { + id: id + }, + { + headers: { + Authorization: `Bearer ${token}`, + token: token + }, + } + ).then((response)=>{ + result = response; + }).catch((error)=>{ + result = error; + }); + return result; } }, }) diff --git a/resources/views/Public.vue b/resources/views/Public.vue index b195dc6..1330cbd 100644 --- a/resources/views/Public.vue +++ b/resources/views/Public.vue @@ -1,19 +1,27 @@ diff --git a/routes/api.php b/routes/api.php index 95e146d..05b25f9 100644 --- a/routes/api.php +++ b/routes/api.php @@ -39,5 +39,6 @@ Route::group(['prefix' => 'wish'], function () { Route::post('destroy', [WishesController::class, 'destroy']); Route::get('by_id/{id}', [WishesController::class, 'getWishById']); Route::post('book', [WishesController::class, 'book']); + Route::post('unbook', [WishesController::class, 'unbook']); }); });