From be03b05191ea71d32ac51a9c188066ac295388fc Mon Sep 17 00:00:00 2001 From: Victor Westerlund Date: Mon, 1 Dec 2025 13:56:42 +0100 Subject: [PATCH] fix: return passed value when setting db row value (#16) Closes #14 From the example in the issue, this can now be fixed like this: ```php final public DateTimeImmutable $date_created { get => new DateTimeImmutable($this->get(Fields::DATE_CREATED->value)); set (DateTimeImmutable $date_created) => new DateTimeImmutable( $this->set(Fields::DATE_CREATED->value, $date_created->format(Database::DATETIME_FORMAT) )); } ``` Reviewed-on: https://codeberg.org/vlw/scaffold/pulls/16 --- src/Database/Model.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Database/Model.php b/src/Database/Model.php index 6327812..fa3a0cf 100644 --- a/src/Database/Model.php +++ b/src/Database/Model.php @@ -97,14 +97,16 @@ * * @param string $key Target column to update * @param mixed $value New value of target column - * @return bool Update was successful + * @return mixed The value that was sent to $value */ - public function set(string $key, mixed $value): bool { + public function set(string $key, mixed $value): mixed { $this->_row[$key] = $value; - return $this->db + $this->db ->from($this->table) ->where($this->where) ->update([$key => $value]); + + return $value; } }