From 4ba989963c7f86c73f68ef4af3a2f6bf33297f79 Mon Sep 17 00:00:00 2001 From: Victor Westerlund Date: Sat, 30 Aug 2025 08:08:44 +0200 Subject: [PATCH] fix: coffee DELETE endpoint missing table reference --- api/coffee/DELETE.php | 3 +-- src/Database/Models/Coffee/Coffee.php | 7 ++++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/api/coffee/DELETE.php b/api/coffee/DELETE.php index 251ad37..1a95fd3 100644 --- a/api/coffee/DELETE.php +++ b/api/coffee/DELETE.php @@ -8,12 +8,11 @@ use VLW\Database\Models\Coffee\Coffee; use VLW\Database\Tables\Coffee\Coffee as CoffeeTable; - require_once Path::root("src/UUID.php"); require_once Path::root("src/API/API.php"); require_once Path::root("src/Database/Models/Coffee/Coffee.php"); require_once Path::root("src/Database/Tables/Coffee/Coffee.php"); - final class POST_Coffee extends API { + final class DELETE_Coffee extends API { public function __construct() { parent::__construct(new Ruleset()->GET([ new Rules(CoffeeTable::ID->value) diff --git a/src/Database/Models/Coffee/Coffee.php b/src/Database/Models/Coffee/Coffee.php index 2f3eafa..c96a67a 100644 --- a/src/Database/Models/Coffee/Coffee.php +++ b/src/Database/Models/Coffee/Coffee.php @@ -3,6 +3,7 @@ namespace VLW\Database\Models\Coffee; use \VV; + use \Exception; use \vlw\MySQL\Order; use \DateTimeImmutable; @@ -61,7 +62,11 @@ } public function delete(): bool { - return $this->db->delete([CoffeeTable::ID->value => $this->id]); + try { + return $this->db->from(CoffeeTable::TABLE)->delete([CoffeeTable::ID->value => $this->id]); + } catch (Exception $error) { + return false; + } } final public DateTimeImmutable $date_created {