Skip to content

Commit

Permalink
fix: fix hardcoded expectation that id is the models primary key
Browse files Browse the repository at this point in the history
  • Loading branch information
tpetry authored Mar 20, 2021
1 parent 49c1872 commit fe629c3
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
) {
return Nova::modelInstanceForKey($resourceName)
->with("tokens")
->where("id", $id)
->first();
->find($id);
});

Route::post("tokens/{resourceName}/{id}", function (
Expand Down Expand Up @@ -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();
});

0 comments on commit fe629c3

Please sign in to comment.