From fe629c376175a20363bbe840331561e997f2229c Mon Sep 17 00:00:00 2001 From: Tobias Petry Date: Sat, 20 Mar 2021 16:51:17 +0100 Subject: [PATCH] fix: fix hardcoded expectation that id is the models primary key --- routes/api.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/routes/api.php b/routes/api.php index 430087e..06b104a 100644 --- a/routes/api.php +++ b/routes/api.php @@ -29,8 +29,7 @@ ) { return Nova::modelInstanceForKey($resourceName) ->with("tokens") - ->where("id", $id) - ->first(); + ->find($id); }); Route::post("tokens/{resourceName}/{id}", function ( @@ -58,11 +57,10 @@ ) { $user = Nova::modelInstanceForKey($resourceName) ->with("tokens") - ->where("id", $id) - ->first(); + ->find($id); return $user ->tokens() - ->where("id", $request->token_id) + ->whereKey($request->token_id) ->delete(); });