Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Fix) Extend donation expiry instead of keeping the old expiry #4445

Draft
wants to merge 1 commit into
base: development
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion app/Http/Controllers/Staff/DonationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,21 @@
$donation = Donation::with(['user', 'package'])->findOrFail($id);
$donation->status = Donation::APPROVED;
$donation->starts_at = $now;
$active_donation = Donation::where('status', '=', Donation::APPROVED)->where('user_id', '=', $donation->user->id)->latest()->first();

if ($donation->package->donor_value > 0) {
$donation->ends_at = $now->addDays($donation->package->donor_value);
if ($donation->user->is_lifetime) {
$donation->ends_at = null;

Check failure on line 79 in app/Http/Controllers/Staff/DonationController.php

View workflow job for this annotation

GitHub Actions / php 8.4 on ubuntu-22.04

Ignored error pattern #^Property App\\Models\\Donation\:\:\$ends_at \(Illuminate\\Support\\Carbon\) does not accept null\.$# in path /home/runner/work/UNIT3D-Community-Edition/UNIT3D-Community-Edition/app/Http/Controllers/Staff/DonationController.php is expected to occur 1 time, but occurred 2 times.
} else {
if (!is_null($active_donation->ends_at) && $donation->user->is_donor) {

Check failure on line 81 in app/Http/Controllers/Staff/DonationController.php

View workflow job for this annotation

GitHub Actions / php 8.4 on ubuntu-22.04

Call to function is_null() with Illuminate\Support\Carbon will always evaluate to false.
$active_donation_expiry = Carbon::parse($active_donation->ends_at);
$donation->ends_at = $active_donation_expiry->addDays($donation->package->donor_value);

Check failure on line 83 in app/Http/Controllers/Staff/DonationController.php

View workflow job for this annotation

GitHub Actions / php 8.4 on ubuntu-22.04

Ignored error pattern #^Property App\\Models\\Donation\:\:\$ends_at \(Illuminate\\Support\\Carbon\) does not accept Carbon\\Carbon\.$# in path /home/runner/work/UNIT3D-Community-Edition/UNIT3D-Community-Edition/app/Http/Controllers/Staff/DonationController.php is expected to occur 1 time, but occurred 2 times.
} else {
$donation->ends_at = $now->addDays($donation->package->donor_value);

Check failure on line 85 in app/Http/Controllers/Staff/DonationController.php

View workflow job for this annotation

GitHub Actions / php 8.4 on ubuntu-22.04

Property App\Models\Donation::$ends_at (Illuminate\Support\Carbon) does not accept Carbon\Carbon.
}
}
} else {
$donation->ends_at = null;

Check failure on line 89 in app/Http/Controllers/Staff/DonationController.php

View workflow job for this annotation

GitHub Actions / php 8.4 on ubuntu-22.04

Property App\Models\Donation::$ends_at (Illuminate\Support\Carbon) does not accept null.
}

$donation->user->invites += $donation->package->invite_value ?? 0;
Expand Down
Loading