From 88785ea4e193b817fd2fa18db67c8ef59447bd78 Mon Sep 17 00:00:00 2001 From: Glauber Silva Date: Wed, 13 Dec 2023 11:30:22 -0300 Subject: [PATCH] feature: add update function --- src/Revenue/Repositories/Revenue.php | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/Revenue/Repositories/Revenue.php b/src/Revenue/Repositories/Revenue.php index 59ef852a5b..f8fb7a93a1 100644 --- a/src/Revenue/Repositories/Revenue.php +++ b/src/Revenue/Repositories/Revenue.php @@ -5,7 +5,6 @@ use Give\Donations\Models\Donation; use Give\Framework\Database\DB; use Give\Framework\Exceptions\Primitives\InvalidArgumentException; -use Give\Framework\Support\ValueObjects\Money; /** * Class Revenue @@ -48,6 +47,29 @@ public function insert($revenueData) ); } + /** + * Update revenue. + * + * @unreleased + * + * @return bool|int + */ + public function update(array $revenueData) + { + global $wpdb; + + // Validate revenue data + $this->validateNewRevenueData($revenueData); + + return DB::update( + $wpdb->give_revenue, + $revenueData, + ['donation_id' => $revenueData['donation_id']], + ['%d'], + ['%d'] + ); + } + /** * Deletes revenue *