fix: /coffee DELETE endpoint incorrectly configured and missing table reference (#50)

Fix class config and missing `from()` method for the `/coffee` DELETE endpoint

Reviewed-on: https://codeberg.org/vlw/vlw.se/pulls/50
This commit is contained in:
Victor Westerlund 2025-08-30 08:27:12 +02:00
parent 85e8e00091
commit 8209ea5ecc
2 changed files with 7 additions and 3 deletions

View file

@ -8,12 +8,11 @@
use VLW\Database\Models\Coffee\Coffee; use VLW\Database\Models\Coffee\Coffee;
use VLW\Database\Tables\Coffee\Coffee as CoffeeTable; 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/API/API.php");
require_once Path::root("src/Database/Models/Coffee/Coffee.php"); require_once Path::root("src/Database/Models/Coffee/Coffee.php");
require_once Path::root("src/Database/Tables/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() { public function __construct() {
parent::__construct(new Ruleset()->GET([ parent::__construct(new Ruleset()->GET([
new Rules(CoffeeTable::ID->value) new Rules(CoffeeTable::ID->value)

View file

@ -3,6 +3,7 @@
namespace VLW\Database\Models\Coffee; namespace VLW\Database\Models\Coffee;
use \VV; use \VV;
use \Exception;
use \vlw\MySQL\Order; use \vlw\MySQL\Order;
use \DateTimeImmutable; use \DateTimeImmutable;
@ -61,7 +62,11 @@
} }
public function delete(): bool { 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 { final public DateTimeImmutable $date_created {