Skip to content

Commit

Permalink
Merge pull request #62 from gte451f/respond-update-with-404-if-not-ex…
Browse files Browse the repository at this point in the history
…ists

The API fails if you try to update a non existent
  • Loading branch information
andyhot authored Feb 1, 2018
2 parents ecc76e4 + c190773 commit d868054
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/API/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -1344,6 +1344,12 @@ public function save($formData, $id = null)

// need parent logic here
$this->model = ($this->model)::findFirst($id);
if (!$this->model) {
throw new HTTPException("Could not find record #$id to update.", 404, [
'dev' => "No record was found to update",
'code' => '293542512610127'
]);
}
$primaryModel = $this->loadParentModel($this->model, $formData);

// // TODO this only works with 1 parent so far....
Expand Down

0 comments on commit d868054

Please sign in to comment.