mirror of
https://codeberg.org/vlw/vlw.se.git
synced 2025-09-14 05:13:46 +02:00
Compare commits
No commits in common. "master" and "2.3.0" have entirely different histories.
4 changed files with 6 additions and 14 deletions
|
@ -8,11 +8,12 @@
|
|||
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 DELETE_Coffee extends API {
|
||||
final class POST_Coffee extends API {
|
||||
public function __construct() {
|
||||
parent::__construct(new Ruleset()->GET([
|
||||
new Rules(CoffeeTable::ID->value)
|
||||
|
|
|
@ -13,10 +13,9 @@
|
|||
|
||||
final class POST_Coffee extends API {
|
||||
public function __construct() {
|
||||
parent::__construct(new Ruleset(strict: true)->POST([
|
||||
parent::__construct(new Ruleset()->POST([
|
||||
new Rules(CoffeeTable::DATE_CREATED->value)
|
||||
->type(Type::STRING)
|
||||
->type(Type::NUMBER)
|
||||
->default(null)
|
||||
]));
|
||||
}
|
||||
|
@ -27,10 +26,7 @@
|
|||
// Parse DateTime from POST string
|
||||
if ($_POST[CoffeeTable::DATE_CREATED->value]) {
|
||||
try {
|
||||
// Create DateTimeImmutable from Unix timestamp or datetime string
|
||||
$datetime = gettype($_POST[CoffeeTable::DATE_CREATED->value]) === "integer"
|
||||
? DateTimeImmutable::createFromTimestamp($_POST[CoffeeTable::DATE_CREATED->value])
|
||||
: new DateTimeImmutable($_POST[CoffeeTable::DATE_CREATED->value]);
|
||||
$datetime = new DateTimeImmutable($_POST[CoffeeTable::DATE_CREATED->value]);
|
||||
} catch (DateMalformedStringException $error) {
|
||||
return new Response($error->getMessage(), 400);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
namespace VLW\Database\Models\Coffee;
|
||||
|
||||
use \VV;
|
||||
use \Exception;
|
||||
use \vlw\MySQL\Order;
|
||||
use \DateTimeImmutable;
|
||||
|
||||
|
@ -62,11 +61,7 @@
|
|||
}
|
||||
|
||||
public function delete(): bool {
|
||||
try {
|
||||
return $this->db->from(CoffeeTable::TABLE)->delete([CoffeeTable::ID->value => $this->id]);
|
||||
} catch (Exception $error) {
|
||||
return false;
|
||||
}
|
||||
return $this->db->delete([CoffeeTable::ID->value => $this->id]);
|
||||
}
|
||||
|
||||
final public DateTimeImmutable $date_created {
|
||||
|
|
2
vegvisir
2
vegvisir
|
@ -1 +1 @@
|
|||
Subproject commit 016b88068212243ce33894fbba9ffa91009146f0
|
||||
Subproject commit 461b2cc82b268ca09919a3506625957a868a9d27
|
Loading…
Add table
Reference in a new issue